From 46d681c6b825d21b3f698d793c4e630c687d90ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Thu, 21 May 2026 21:41:53 +0000
Subject: [PATCH] =Major CustomBlocks.php overhaul, expanding block support and customization from the editor. theme.json should now be updated on new themes to set brand colours, etc. Also note: major change to .col vs .row alignment: simplifying it to .top .bottom vs the confusion of the differences for .col/.row .start and .a-start
---
inc/blocks/SummaryBlock.php | 40 +++++++++++++++++++++++++++-------------
1 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/inc/blocks/SummaryBlock.php b/inc/blocks/SummaryBlock.php
index 3464a59..ecf01ac 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>
+ <details class="info"<?=$open?>>
+ <summary class="row x-btw"><?= $this->detailsTitle ?></summary>
<?php
foreach ($this->details as $key => $details) {
if ($details === '') {
@@ -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