Jake Vanderwerf
2026-03-29 275c0d74cd68677622a5431505c5c870c473063d
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)
@@ -139,6 +158,9 @@
            <?php endif; ?>
        </header>
        <?php
      if (!empty($this->beforeSummary)) {
         echo $this->beforeSummary;
      }
    }
    protected function renderDetails():void
@@ -149,8 +171,9 @@
        if (empty($details)) {
            return;
        }
      $open = $this->isOpen ? ' open' : '';
        ?>
        <details class="info">
        <details class="info"<?=$open?>>
            <summary class="row btw"><?= $this->detailsTitle ?></summary>
            <?php
            foreach ($this->details as $key => $details) {
@@ -173,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