Jake Vanderwerf
2026-01-06 2c955cebb5f1e01fbdb866b50d296fe9fbd852b8
inc/meta/MetaManager.php
@@ -25,6 +25,8 @@
   protected string|null $object_type;
   protected int $max_file_size = 5242880;
   protected ?string $content = null;
   protected ?string $baseKey = null;
   protected \wpdb $wpdb;
   protected array $postFields = [
      'post_title',
@@ -49,12 +51,11 @@
      'description'
   ];
   public function __construct(?int $ID = null, ?string $type = null, ?string $content = null)
   public function __construct(int|string|null $ID = null, ?string $type = null, ?string $content = null)
   {
      global $wpdb;
      $this->wpdb = $wpdb;
      $this->object_id = $ID;
      $this->object_id = is_int($ID) ? $ID : null;
      $this->object_type = $type;
      if ($ID) {
         switch ($type) {
@@ -68,6 +69,10 @@
            case 'integrations':
               $this->data = get_user($ID);
               break;
            case 'options':
               $this->baseKey = $ID;
               $this->data = null;
               break;
            default:
               $this->data = null;
               break;
@@ -146,7 +151,10 @@
         case 'integrations':
            return get_user_meta($this->object_id, $meta_key, true);
         case 'options':
            return get_option($meta_key);
            $key = $this->baseKey
               ? BASE . $this->baseKey . '_' . $name
               : BASE . $name;
            return get_option($key);
         default:
            return '';
      }
@@ -333,11 +341,7 @@
               }
         }
         if ($field_config['type'] == 'taxonomy' && (!array_key_exists('taxonomy_type', $field_config))) {
            error_log('Attempting to set taxonomies: ' . print_r($this->object_id, true));
            error_log('Sanitized data: ' . print_r($sanitized, true));
            error_log('Taxonomy: ' . print_r($field_config['taxonomy'], true));
            $set = wp_set_post_terms($this->object_id, $sanitized, jvbCheckBase($field_config['taxonomy']), false);
            error_log('Set post terms: ' . print_r($set, true));
         }
         if ($field_config['type'] === 'location' && empty($sanitized)) {
            $this->addMeta('has_map', false);
@@ -358,7 +362,10 @@
               $result = update_user_meta($this->object_id, $meta_key, $sanitized);
               break;
            case 'options':
               $result = update_option($meta_key, $sanitized);
               $key = $this->baseKey
                  ? BASE . $this->baseKey . '_' . $name
                  : BASE . $name;
               return update_option($key, $sanitized);
         }
         if ($result === false) {
@@ -1020,7 +1027,8 @@
               }
               if ($field_config['type'] === 'taxonomy' && !array_key_exists('taxonomy_type', $field_config)){
                  $set = wp_set_post_terms($this->object_id, $sanitized, jvbCheckBase($field_config['taxonomy']), false);
                  $term_ids = array_map('intval', explode(',', trim($sanitized)));
                  $set = wp_set_post_terms($this->object_id, $term_ids, jvbCheckBase($field_config['taxonomy']), false);
               }
               if ($field_config['type'] === 'location' && empty($sanitized)) {