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 | 64 +++++++++++---------------------
1 files changed, 22 insertions(+), 42 deletions(-)
diff --git a/inc/meta/MetaManager.php b/inc/meta/MetaManager.php
index 9da898e..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
@@ -13,13 +11,16 @@
/**
* Core meta management class
*/
+
+/**
+ * @deprecated Use Meta() now
+ */
class MetaManager
{
public MetaTypeManager $type_manager;
- public MetaValidator $validator;
- public MetaSanitizer $sanitizer;
- public MetaRenderer $renderer;
- public MetaForm $form;
+ public Validator $validator;
+ public Sanitizer $sanitizer;
+ public Render $renderer;
protected int|null $object_id;
public object|null $data;
protected array $fields =[];
@@ -68,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);
@@ -90,10 +92,9 @@
}
$this->type_manager = new MetaTypeManager();
- $this->validator = new MetaValidator();
- $this->sanitizer = new MetaSanitizer();
- $this->renderer = new MetaRenderer();
- $this->form = new MetaForm();
+ $this->validator = new Validator();
+ $this->sanitizer = new Sanitizer();
+ $this->renderer = new Render();
}
/**
@@ -536,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;
}
@@ -587,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
@@ -690,11 +678,11 @@
$out = '';
switch ($type) {
case 'form':
- $out = $this->form->render($name, $value, $config, $showHidden, true);
+ $out = Form::render($name, $value, $config);
$out = apply_filters('jvbRenderFormMeta', $out, $name, $config, $value, $this->getObjectType());
break;
case 'render':
- $out = $this->renderer->render($name, $value, $config, true);
+ $out = $this->renderer->render($name, $value, $config);
if (empty($out) && !$hideEmpty) {
$out = $this->getEmptyTemplate($config['type'], $name);
}
@@ -727,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