Jake Vanderwerf
2026-02-10 0c268f3b56604367ca5dfe887d07774cdbe553e5
inc/meta/Storage.php
@@ -34,6 +34,16 @@
         return $this->getWpDefault($item, $name);
      }
      // Taxonomy fields are stored in term_relationships, not meta
      $config = $item->getFieldConfig($name);
      if ($config
         && (
            ($config['type'] ?? '') === 'taxonomy'
            || (($config['type']??'') === 'selector' && ($config['subtype']??'') === 'taxonomy')
         ) && !isset($config['taxonomy_type'])) {
         return $this->getTaxonomyField($item, $config);
      }
      $metaKey = BASE . $name;
      return match ($item->objectType) {
@@ -56,23 +66,52 @@
      $defaults = Item::WP_DEFAULTS[$item->objectType] ?? [];
      $wpFields = array_intersect($defaults, $fieldNames);
      $metaFields = array_diff($fieldNames, $wpFields);
      // Separate taxonomy fields from regular meta fields
      $taxonomyFields = [];
      $metaFields = [];
      foreach (array_diff($fieldNames, $wpFields) as $name) {
         $config = $item->getFieldConfig($name);
         if ($config
            && (
               ($config['type'] ?? '') === 'taxonomy'
               || (($config['type']??'') === 'selector' && ($config['subtype']??'') === 'taxonomy')
            ) && !isset($config['taxonomy_type'])) {
            $taxonomyFields[$name] = $config;
         } else {
            $metaFields[] = $name;
         }
      }
      $values = [];
      // Get meta fields in bulk query
      if (!empty($metaFields)) {
         $values = $this->bulkGetMeta($item, $metaFields);
      }
      // Get WP default fields
      foreach ($wpFields as $name) {
         $values[$name] = $this->getWpDefault($item, $name);
      }
      foreach ($taxonomyFields as $name => $config) {
         $values[$name] = $this->getTaxonomyField($item, $config);
      }
      return $values;
   }
   protected function getTaxonomyField(Item $item, array $config): string
   {
      $taxonomy = jvbCheckBase($config['taxonomy']);
      $terms = wp_get_object_terms($item->id, $taxonomy, ['fields' => 'ids']);
      if (is_wp_error($terms) || empty($terms)) {
         return '';
      }
      return implode(',', $terms);
   }
   /**
    * Save a single field
    */