From a24a06002081ad71a78ffeff9072725ba39cf121 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 17 Feb 2026 20:05:31 +0000
Subject: [PATCH] =minor changes, particularly around the JVB_CHILD_URL pattern

---
 inc/managers/DirectoryManager.php |   69 +++++++++++++++++++++++-----------
 1 files changed, 47 insertions(+), 22 deletions(-)

diff --git a/inc/managers/DirectoryManager.php b/inc/managers/DirectoryManager.php
index d724af6..f8048b6 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,
@@ -130,16 +127,17 @@
 
 	}
 
-    public function activate()
+    public static function activate()
     {
-		$this->registerDirectories();
+		$tmp = new self();
+		$tmp->registerDirectories();
 
         $created = [];
         $directories = [];
 
-		foreach($this->directories as $directory => $type) {
-			$config = $this->getConfigFromType($directory);
-			$title = $this->directoryTitle($config);
+		foreach($tmp->directories as $directory => $type) {
+			$config = $tmp->getConfigFromType($directory);
+			$title = $tmp->directoryTitle($config);
 			$excerpt = implode(' ', $config['description']??[]);
 			$ID = wp_insert_post([
 				'post_type'	=> BASE.'directory',
@@ -229,6 +227,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 +264,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 +470,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 +514,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 +605,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