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/ui/CRUDSkeleton.php |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/inc/ui/CRUDSkeleton.php b/inc/ui/CRUDSkeleton.php
index c32dcce..c8eeda1 100644
--- a/inc/ui/CRUDSkeleton.php
+++ b/inc/ui/CRUDSkeleton.php
@@ -3,6 +3,7 @@
 
 use JVBase\managers\UserTermsManager;
 use JVBase\meta\Form;
+use JVBase\registrar\Registrar;
 use WP_User;
 
 if (!defined('ABSPATH')) {
@@ -128,6 +129,7 @@
 	protected array $customDateRanges = [];
 	protected array $additionalClasses = [];
 
+	protected Registrar $registrar;
 	public function __construct() {
 		$this->icon = jvbDefaultIcon();
 		$this->user = wp_get_current_user();
@@ -148,6 +150,7 @@
 	 */
 	public function content(string $type, string $singular, string $plural): self {
 		$this->dataType = $type;
+		$this->registrar = Registrar::getInstance($type);
 		$this->singular = $singular;
 		$this->plural = $plural;
 		return $this;
@@ -213,12 +216,13 @@
 	 */
 	public function addTaxonomyFilter(array $taxonomies, ?string $limit = null): self {
 		foreach($taxonomies as $taxonomy) {
+			$registrar = Registrar::getInstance($taxonomy);
 			$this->taxonomies[$taxonomy] = [
 				'type'	=> 'taxonomy',
 				'taxonomy'=> $taxonomy,
 				'limit'	=> $limit,
-				'label'	=> JVB_TAXONOMY[$taxonomy]['plural']??'',
-				'icon'	=> JVB_TAXONOMY[$taxonomy]['icon']??''
+				'label'	=> $registrar->getPlural(),
+				'icon'	=> $registrar->getIcon()
 			];
 		}
 
@@ -228,7 +232,7 @@
 	protected function taxConfig(string $taxonomy, string $label = ''):array
 	{
 		$isVerified = jvbUserIsVerified();
-		$label = ($label === '') ? JVB_TAXONOMY[$taxonomy]['plural'] : $label;
+		$label = ($label === '') ? Registrar::getInstance($taxonomy)->getPlural() : $label;
 		return [
 			'type'		=> 'taxonomy',
 			'label'		=> $label,
@@ -973,9 +977,11 @@
 					<option value="<?=$control?>"<?=$disabled?>><?=$label?></option>
 					<?php
 				}
-				foreach ($this->taxonomies as $taxonomy => $config) {
+				foreach ($this->taxonomies as $taxonomy) {
+					$registrar = Registrar::getInstance($taxonomy);
+					if (!$registrar) continue;
 					?>
-					<option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=JVB_TAXONOMY[$taxonomy]['singular']?>" data-plural="<?=JVB_TAXONOMY[$taxonomy]['plural']?>" data-taxonomy="<?=$taxonomy?>">Add to <?= JVB_TAXONOMY[$taxonomy]['singular']??$config['label'] ?></option>
+					<option value="tax-<?=$taxonomy?>" data-type="selector" data-single="<?=$registrar->getSingular()?>" data-plural="<?=$registrar->getPlural()?>" data-taxonomy="<?=$taxonomy?>">Add to <?= $registrar->getSingular() ?></option>
 					<?php
 				}
 				?>
@@ -1549,7 +1555,8 @@
 
 				if (!empty($this->sections)) {
 					$tabs = [];
-					foreach ($this->sections as $slug => $config) {
+					foreach ($this->sections as $config) {
+						$slug = $config['slug'];
 						$section = [];
 						if (array_key_exists('icon', $config)) {
 							$section = [
@@ -1561,10 +1568,6 @@
 							'content' => '',
 							'description' => $config['description']??'',
 						], $section);
-						$icon = jvbSectionIcon($slug);
-						if ($icon !== '') {
-							$tabs[$slug]['icon'] = $icon;
-						}
 					}
 				} else {
 					$tabs = false;
@@ -1621,6 +1624,7 @@
 						$section = (array_key_exists('section', $config)) ? $config['section'] : 'basic';
 						$tabs[$section]['content'] .= Form::render($n, '', $config);
 					} else {
+						jvbDump($config, $n);
 						echo Form::render($n, '', $config);
 					}
 				}

--
Gitblit v1.10.0