From c32ed859f4abd1591c882f4f2a6ee16b1ec275e2 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 12 May 2026 14:03:27 +0000
Subject: [PATCH] =A little form recovery magic

---
 inc/forms/TaxonomySelector.php |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/inc/forms/TaxonomySelector.php b/inc/forms/TaxonomySelector.php
index 9409b61..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);
@@ -272,12 +279,12 @@
 	{
 		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>',
-			JVB_TAXONOMY[$this->name]['icon'],
+			$this->registrar->getIcon(),
 			$this->name,
 			$this->singular,
 			$this->plural,
 			$this->singular,
-			jvbIcon($this->config['icon']),
+			jvbIcon($this->registrar->getIcon()),
 			$this->singular
 		);
 	}
@@ -342,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