From d7e7d248cbe41cd7a9ef9c2fb022b6c4831f99a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 31 May 2026 15:22:56 +0000
Subject: [PATCH] =jakevan complete

---
 inc/blocks/SummaryBlock.php |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/inc/blocks/SummaryBlock.php b/inc/blocks/SummaryBlock.php
index 3464a59..88aaa8c 100644
--- a/inc/blocks/SummaryBlock.php
+++ b/inc/blocks/SummaryBlock.php
@@ -18,6 +18,8 @@
     protected string $image;
     protected string $header;
     protected string $headerExtra;
+	protected bool $isOpen = false;
+    protected string $beforeSummary;
     protected string $detailsTitle;
     protected array $details;
 
@@ -25,6 +27,7 @@
     {
         $this->cache = Cache::for('summary_block', WEEK_IN_SECONDS);
         add_action('init', [ $this, 'registerBlock' ]);
+		add_action('wp_enqueue_scripts', [$this, 'enqueueScripts']);
 		if (JVB_TESTING) {
 			$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';
@@ -86,6 +94,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 +108,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)
@@ -124,7 +143,6 @@
 
     protected function renderHeader():void
     {
-		ob_start();
         ?>
         <header id="top">
             <?php if ($this->image !== ''): ?>
@@ -140,15 +158,9 @@
             <?php endif; ?>
         </header>
         <?php
-		$out = ob_get_clean();
-
-
-		echo apply_filters(
-			'jvbSummaryHeaderOutput',
-			$out,
-			$this->header,
-			$this->headerExtra
-		);
+		if (!empty($this->beforeSummary)) {
+			echo $this->beforeSummary;
+		}
     }
 
     protected function renderDetails():void
@@ -159,9 +171,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 === '') {
@@ -174,7 +187,7 @@
             <?php
             }
             ?>
-        </details>
+        </details></section>
         <?php
     }
 
@@ -183,7 +196,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