From 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Aug 2026 22:57:22 +0000
Subject: [PATCH] =It's been a minute. I went through the Routes and associated Managers and ensured they played together well. Reworked the Cache.php, and I think I caught all the references. Moving away from JVBase() root class, to individuall classes that are Instanced. Double checked for the ABSPATH check in every file, and added index.php to every directory that didn't already have it. Also still working on the MenuBlock to work with WooCommerce for now for Northeh

---
 inc/blocks/SummaryBlock.php |   50 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/inc/blocks/SummaryBlock.php b/inc/blocks/SummaryBlock.php
index 84d99b3..186ebbd 100644
--- a/inc/blocks/SummaryBlock.php
+++ b/inc/blocks/SummaryBlock.php
@@ -1,7 +1,7 @@
 <?php
 namespace JVBase\blocks;
 
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
 use JVBase\forms\TaxonomySelector;
 use WP_Block;
 
@@ -11,22 +11,25 @@
 
 class SummaryBlock
 {
-    protected CacheManager $cache;
+    protected Cache $cache;
     protected string $config;
     protected string $type;
     protected string $path = JVB_DIR . '/build/summary';
     protected string $image;
     protected string $header;
     protected string $headerExtra;
+	protected bool $isOpen = false;
+    protected string $beforeSummary;
     protected string $detailsTitle;
     protected array $details;
 
     public function __construct()
     {
-        $this->cache = CacheManager::for('summary_block', WEEK_IN_SECONDS);
+        $this->cache = Cache::for('summary_block', 'post', WEEK_IN_SECONDS);
         add_action('init', [ $this, 'registerBlock' ]);
+		add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']);
 		if (JVB_TESTING) {
-			$this->cache->clear();
+			$this->cache->flush();
 		}
     }
 
@@ -37,6 +40,11 @@
         ]);
     }
 
+	public function enqueueScripts():void
+	{
+		wp_enqueue_script('jvb-page-nav');
+	}
+
     protected function getConfig():string
     {
         return (is_tax()) ? 'tax' : 'content';
@@ -57,7 +65,15 @@
     {
         $this->config = $this->getConfig();
         $key = $this->generateKey();
-        $cache = $this->cache->get($key);
+		if (is_tax()) {
+			$this->cache = Cache::for('summary_tax', 'term', WEEK_IN_SECONDS);
+		} elseif (is_author()) {
+			$this->cache = Cache::for('summary_auth', 'user', WEEK_IN_SECONDS);
+		} else {
+			$this->cache = Cache::for('summary_post', 'post', WEEK_IN_SECONDS);
+		}
+
+        $cache = $this->cache->get(get_queried_object_id());
 
         if ($cache) {
             return $cache;
@@ -86,6 +102,11 @@
         );
         $this->headerExtra = ($headerExtra === '') ? '' : '<div>'.$headerExtra.'</div>';
 
+		$this->beforeSummary = apply_filters(
+			'jvbBeforeSummary',
+			'',
+			$this->getType()
+		);
         /**
          * The HTML string that appears within the <summary> block
          */
@@ -95,6 +116,12 @@
             $this->getType()
         );
 
+		$this->isOpen = apply_filters(
+			'jvbSummaryIsOpen',
+			false,
+			$this->getType()
+		);
+
         /**
          * The content of the <details> block.
          * This should return either an empty array for no information (so no details block)
@@ -139,6 +166,9 @@
             <?php endif; ?>
         </header>
         <?php
+		if (!empty($this->beforeSummary)) {
+			echo $this->beforeSummary;
+		}
     }
 
     protected function renderDetails():void
@@ -149,9 +179,10 @@
         if (empty($details)) {
             return;
         }
+		$open = $this->isOpen ? ' open' : '';
         ?>
-        <details class="info">
-            <summary class="row btw"><?= $this->detailsTitle ?></summary>
+        <section><details class="info"<?=$open?>>
+            <summary class="row x-btw"><?= $this->detailsTitle ?></summary>
             <?php
             foreach ($this->details as $key => $details) {
                 if ($details === '') {
@@ -164,7 +195,7 @@
             <?php
             }
             ?>
-        </details>
+        </details></section>
         <?php
     }
 
@@ -173,7 +204,8 @@
         if (empty($this->details)) {
             return;
         }
-        echo jvbOnThisPage(array_keys($this->details));
+		$IDs = apply_filters('jvbSummaryOnThisPage', array_keys($this->details), $this->getType());
+        echo jvbOnThisPage($IDs);
     }
 
     protected function getType():string

--
Gitblit v1.10.0