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/forms/TaxonomySelector.php |   53 ++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 34 insertions(+), 19 deletions(-)

diff --git a/inc/forms/TaxonomySelector.php b/inc/forms/TaxonomySelector.php
index f9d252b..5af59da 100644
--- a/inc/forms/TaxonomySelector.php
+++ b/inc/forms/TaxonomySelector.php
@@ -1,6 +1,7 @@
 <?php
 namespace JVBase\forms;
 
+use JVBase\registrar\Registrar;
 use WP_Term;
 
 if (!defined('ABSPATH')) {
@@ -27,13 +28,19 @@
 	protected string $base;
 	protected string $title;
 	protected array $config;
+	protected Registrar $registrar;
 
 	public function __construct(string $id, string $taxonomy, array $config = []) {
 		$this->id = sanitize_key($id);
 		$this->taxonomy = jvbCheckBase($taxonomy);
 		$this->name = jvbNoBase($taxonomy);
 
-		$this->title = JVB_TAXONOMY[$this->name]['plural'];
+		$registrar = Registrar::getInstance($this->name);
+		if ($registrar) {
+			$this->registrar = $registrar;
+		}
+
+		$this->title = $registrar->getPlural();
 		$this->base = $config['base']??'';
 		$this->config = wp_parse_args($config, [
 			'types'		=> false, // for feed block implementation
@@ -50,8 +57,8 @@
 			'update'	=> true,   // Whether to update on close
 		]);
 
-		$this->plural = JVB_TAXONOMY[$taxonomy]['plural'];
-		$this->singular = JVB_TAXONOMY[$taxonomy]['singular'];
+		$this->plural = $registrar->getPlural();
+		$this->singular = $registrar->getSingular();
 	}
 
 
@@ -64,14 +71,14 @@
 	 */
 	public static function getTermPath(WP_Term $term, bool $returnArray = false): string|array {
 		if (!is_taxonomy_hierarchical($term->taxonomy)) {
-			return $term->name;
+			return html_entity_decode($term->name);
 		}
 
 		$path = [];
 		$currentTerm = $term;
 
 		while ($currentTerm) {
-			array_unshift($path, $currentTerm->name);
+			array_unshift($path, html_entity_decode($currentTerm->name));
 
 			if ($currentTerm->parent) {
 				$currentTerm = get_term($currentTerm->parent);
@@ -118,14 +125,15 @@
 						</button>
 					</nav>
 
+
+					<p class="message" hidden aria-live="polite">
+						{ <span>loading items</span> }
+					</p>
 					<!-- Terms list -->
 					<ul class="items-container col start" role="listbox" aria-label="Available terms">
 						<!-- Terms will be populated here -->
 					</ul>
 
-					<p class="message" hidden aria-live="polite">
-						{ <span>loading items</span> }
-					</p>
 					<button class="submit-term" hidden data-ignore><strong>Create: </strong> "<span></span>"</button>
 
 					<!-- Infinite scroll sentinel -->
@@ -135,7 +143,7 @@
 				<!-- Search section -->
 				<div class="search-wrapper">
 					<div class="search-bar">
-						<?= jvbSearch('Search terms') ?>
+						<?= jvbSearch('Search terms', 'search-terms') ?>
 					</div>
 				</div>
 
@@ -155,8 +163,6 @@
 									<option value="0">None (Top Level)</option>
 								</select>
 							</div>
-
-							<button type="button" class="submit-term">Add Term</button>
 						</form>
 
 					</div>
@@ -168,14 +174,14 @@
 			<p>{ <span>loading items</span> }</p>
 		</template>
 		<template class="autocompleteItem">
-			<button class="autocomplete item" type="button" data-autocomplete-select></button>
+			<li class="autocomplete item btn"></li>
 		</template>
 		<template class="noTermResults">
 			<p>{ <span>nothing found</span> }</p>
 		</template>
 		<template class="termListItem">
 			<li>
-				<input type ="checkbox">
+				<input type="checkbox">
 				<label>
 					<span class="term-name"></span>
 				</label>
@@ -241,13 +247,13 @@
 				</button>
 				<?php if ($hasAutocomplete !== '') { ?>
 					<input type="text" id="<?= $this->base ?><?= esc_attr($this->config['name']) ?>-autocomplete" autocomplete="off" data-ignore data-autocomplete>
+					<p class="message" hidden aria-live="polite">
+						{ <span>loading items</span> }
+					</p>
 					<div class="auto-wrapper" hidden>
 						<ul class="search-results">
 						</ul>
-						<p class="message" hidden aria-live="polite">
-							{ <span>loading items</span> }
-						</p>
-						<button class="submit-term" hidden data-ignore><strong>Create: </strong>"<span></span>"</button>
+						<button class="submit-term" hidden data-ignore><strong>Create: </strong> "<span></span>"</button>
 					</div>
 
 				<?php } ?>
@@ -271,7 +277,16 @@
 
 	protected function renderTaxonomyToggle(array $selected = [], string $extra = ''): string
 	{
-		return '<button type="button" data-filter="taxonomy" data-taxonomy="'.$this->name.'" title="Filter by '.$this->singular.'">'.jvbIcon($this->config['icon']).'<span class="label">'.$this->singular.'</span></button>';
+		return sprintf(
+			'<button type="button" data-icon="%s" data-filter="taxonomy" data-taxonomy="%s" data-type="selector" data-single="%s" data-plural="%s" title="Filter by %s">%s<span class="label">%s</span></button>',
+			$this->registrar->getIcon(),
+			$this->name,
+			$this->singular,
+			$this->plural,
+			$this->singular,
+			jvbIcon($this->registrar->getIcon()),
+			$this->singular
+		);
 	}
 
 	/**
@@ -334,7 +349,7 @@
 			<span><?= esc_html($termPath) ?></span>
 			<button type="button"
 					class="remove-term row"
-					aria-label="Remove <?= esc_attr($term->name) ?>">
+					aria-label="Remove <?= html_entity_decode($term->name) ?>">
 				<?= jvbIcon('x') ?>
 			</button>
 		</div>

--
Gitblit v1.10.0