From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/meta/MetaManager.php | 42 ++++++++++--------------------------------
1 files changed, 10 insertions(+), 32 deletions(-)
diff --git a/inc/meta/MetaManager.php b/inc/meta/MetaManager.php
index 4fe121f..7dcc0af 100644
--- a/inc/meta/MetaManager.php
+++ b/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;
--
Gitblit v1.10.0