From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/managers/DirectoryManager.php |   58 +++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/inc/managers/DirectoryManager.php b/inc/managers/DirectoryManager.php
index d724af6..dc591ef 100644
--- a/inc/managers/DirectoryManager.php
+++ b/inc/managers/DirectoryManager.php
@@ -6,6 +6,7 @@
 }
 
 use JVBase\registry\PostTypeRegistrar;
+use JVBase\managers\Cache;
 use JVBase\utility\Features;
 use WP_Block;
 use WP_Query;
@@ -18,7 +19,7 @@
 	protected int $perPage;
     protected static string $type = BASE.'for_type';
     protected static string $slug = BASE.'for_type_slug';
-    protected CacheManager $cache;
+    protected Cache $cache;
 
     public function __construct($perPage = 100)
     {
@@ -27,20 +28,16 @@
             return;
         }
 		$this->perPage = $perPage;
-        $this->cache = CacheManager::for('directory', WEEK_IN_SECONDS);
+        $this->cache = Cache::for('directory', WEEK_IN_SECONDS);
+		$this->cache->connect('post', true)
+			->connect('taxonomy', true)
+			->connect('user', true);
+
 		if (JVB_TESTING) {
-			$this->cache->clear();
+			$this->cache->flush();
 		}
 
-		foreach(['content','taxonomy','user'] as $key) {
-			if (array_key_exists($key, $this->directories)) {
-				$this->cache->connectTo($key);
-			}
-		}
-
-
 		add_action('init', [$this, 'registerDirectories']);
-		jvb_register_do_once('directories_registered', [$this, 'activate']);
         add_action('render_block', [$this, 'renderBlock'], 99999, 3);
     }
 
@@ -68,7 +65,7 @@
 			'public'              => true,
 			'menu_icon'		=> jvbCSSIcon('list-dashes'),
 			'publicly_queryable'    => true,
-			'show_in_menu'          => false,
+			'show_in_menu'          => true,
 			'show_in_admin_bar'     => false,
 			'has_archive'           => true,
 			'hierarchical'			=> true,
@@ -229,6 +226,33 @@
         }
     }
 
+	protected function buildDirectoryList():array
+	{
+		$saved = get_option(BASE.'directory_list', []);
+		if (empty($saved)) {
+			$all = new WP_Query([
+				'post_type'	=> BASE.'directory',
+				'post_status'	=> 'publish',
+				'posts_per_page'	=> -1,
+			]);
+			foreach($all->posts as $post) {
+				$saved[$post->post_name] = [
+					'slug'	=> $post->post_name,
+					'title'	=> $post->post_title,
+					'ID'	=> $post->ID,
+					'url'	=> get_the_permalink($post->ID),
+					'page'	=> $post->post_title,
+					'description'	=> $this->getConfigFromType($post->post_name)['description']??'',
+					'type'	=> get_post_meta($post->ID, self::$type,true),
+					'extra'	=> $this->getConfigFromType($post->post_name)['directory_extra']??[],
+				];
+			}
+			update_option(BASE.'directory_list', $saved);
+			wp_reset_postdata();
+		}
+		return $saved;
+	}
+
 	public function getDirectoryPageIDs():array
 	{
 		if (empty($this->directoryPageIDs)) {
@@ -239,7 +263,7 @@
 	public function getDirectoryList():array
 	{
 		if (empty($this->directoryList)) {
-			$this->directoryList = get_option(BASE.'directory_list', []);
+			$this->directoryList = $this->buildDirectoryList();
 		}
 		return $this->directoryList;
 	}
@@ -445,7 +469,7 @@
 										if ( $terms && ! is_wp_error( $terms ) ) {
 											$term    = $terms[0];
 											$extra[] = [
-												'name' => (get_term_meta( $term->term_id, BASE . 'singular', true ) !== '') ? get_term_meta( $term->term_id, BASE . 'singular', true ) : $term->name,
+												'name' => (get_term_meta( $term->term_id, BASE . 'singular', true ) !== '') ? get_term_meta( $term->term_id, BASE . 'singular', true ) : html_entity_decode($term->name),
 												'url'  => get_term_link( $term->term_id, $item ),
 												'id'   => $term->term_id,
 												'type' => $item,
@@ -489,7 +513,7 @@
 
 								$list = $this->alphabetizeMe(
 									$list,
-									$term->name,
+									html_entity_decode($term->name),
 									get_term_link( $term->term_id, jvbCheckBase( $slug ) ),
 									$term->term_id,
 									$extra
@@ -580,11 +604,11 @@
 			$children =$this->renderListChunk($taxonomy, $term->term_id);
 			$out .= '<li>';
 			if ($children !== '') {
-				$out .= '<details class="term"><summary class="row btw"><a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.$term->name.'</a></summary>';
+				$out .= '<details class="term"><summary class="row btw"><a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.html_entity_decode($term->name).'">'.$term->name.'</a></summary>';
 				$out .= $children;
 				$out .= '</details>';
 			} else {
-				$out .= '<a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.$term->name.'</a>';
+				$out .= '<a href="'.get_term_link($term->term_id, $term->taxonomy).'" title="See more '.$term->name.'">'.html_entity_decode($term->name).'</a>';
 			}
 			$out .= '</li>';
         }

--
Gitblit v1.10.0