Jake Vanderwerf
2026-03-03 772462eeca3002a1d52508aeba485aab2b4742ad
inc/meta/MetaManager.php
@@ -1,10 +1,8 @@
<?php
namespace JVBase\meta;
use DateTime;
use Exception;
use JVBase\utility\Features;
use WP_Post;
use JVBase\registrar\Registrar;
if (!defined('ABSPATH')) {
    exit; // Exit if accessed directly
@@ -71,7 +69,8 @@
            case 'post':
               $this->data = get_post((string)$ID);
               $this->content = jvbNoBase($this->data->post_type);
               $this->isTimeline = Features::forContent($this->content)->has('is_timeline');
               $registrar = Registrar::getInstance($this->content);
               $this->isTimeline = $registrar && $registrar->hasFeature('is_timeline');
               break;
            case 'term':
               $this->data = get_term($ID);
@@ -538,13 +537,13 @@
            $type = jvbUserRole((int)$this->object_id);
            break;
         case 'options':
            return jvbGetFields('options');
            return Registrar::getFieldsFor('options');
      }
      if (!$type) {
         return [];
      }
      $this->fields = jvbGetFields($type, $this->object_type);
      $this->fields = Registrar::getFieldsFor($type);
      return $this->fields;
   }
@@ -589,22 +588,9 @@
      if (!$type) {
         return [];
      }
      return jvbGetSections($type, $this->object_type);
      return Registrar::getInstance($type)->getSections()??[];
   }
    protected function getRegistry():mixed
    {
        switch ($this->object_type) {
            case 'post':
                return JVB_CONTENT[jvbNoBase(get_post_type((int)$this->object_id))]??null;
            case 'term':
                $term = get_term((int)$this->object_id);
                return JVB_TAXONOMY[jvbNoBase($term->taxonomy)]??null;
            case 'user':
                return JVB_USER;
        }
        return null;
    }
    /**
     * @param string $message
@@ -729,26 +715,18 @@
      }
      if (empty($fields)) {
         $fields = ($this->content) ? jvbGetFields($this->content, $this->object_type) : $this->getFields();
         $fields = ($this->content) ? Registrar::getFieldsFor($this->content) : $this->getFields();
      }
      if ($sections !== false && empty($sections)) {
         $sections = ($this->content) ? jvbGetSections($this->content, $this->object_type) : $this->getSections();
         $sections = ($this->content) ? Registrar::getInstance($this->content)->getSections() : $this->getSections();
      }
      if (!empty($sections)){
         $tabs = [];
         foreach ($sections as $slug => $title) {
            $tabs[$slug] = [
               'title'  => $title,
               'content' => '',
               'description' => jvbSectionDescription($slug)??'',
            ];
            $icon = jvbSectionIcon($slug);
            if ($icon !== '') {
               $tabs[$slug]['icon'] = $icon;
            }
         foreach ($sections as $config) {
            $tabs[$config['slug']] = $config;
         }
      } else {
         $tabs = false;