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/MenuBlock.php | 46 ++++++++++++++++++++++------------------------
1 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/inc/blocks/MenuBlock.php b/inc/blocks/MenuBlock.php
index e52f2a2..89b9c60 100644
--- a/inc/blocks/MenuBlock.php
+++ b/inc/blocks/MenuBlock.php
@@ -1,9 +1,11 @@
<?php
namespace JVBase\blocks;
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
use JVBase\forms\TaxonomySelector;
-use JVBase\meta\MetaManager;
+use JVBase\meta\Form;
+use JVBase\meta\Meta;
+use JVBase\meta\Render;
use WP_Block;
use WP_Query;
@@ -13,7 +15,7 @@
class MenuBlock
{
- protected CacheManager $cache;
+ protected Cache $cache;
protected string $config;
protected string $type;
protected string $path = JVB_DIR . '/build/menu';
@@ -27,7 +29,7 @@
public function __construct()
{
- $this->cache = CacheManager::for('menu', WEEK_IN_SECONDS)->connectTo('post', 'menu_item');
+ $this->cache = Cache::for('menu', WEEK_IN_SECONDS)->connectTo('post', 'menu_item');
add_action('init', [ $this, 'registerBlock' ]);
}
@@ -57,16 +59,14 @@
return '';
}
$key = $this->cache->generateKey($this->params);
- $cache = $this->cache->get($key);
- if ($cache) {
- return $cache;
- }
-
- ob_start();
- $this->renderBlock();
- $content = ob_get_clean();
- $this->cache->set($key, $content);
- return $content;
+ return $this->cache->remember(
+ $key,
+ function() {
+ ob_start();
+ $this->renderBlock();
+ return ob_get_clean();
+ }
+ );
}
protected function renderBlock():void
@@ -106,8 +106,8 @@
protected function getSections():array
{
if (!$this->sections) {
- $options = new MetaManager(null, 'options');
- $sections = $options->getValue('menu_section_order');
+ $options = Meta::forOptions('options');
+ $sections = $options->get('menu_section_order');
if (!is_array($sections)) {
$sections = [];
}
@@ -155,7 +155,7 @@
}
protected function renderMenuItem(int $ID, string $slug, string $postType = 'menu_item') {
- $meta = new MetaManager($ID, 'post');
+ $meta = Meta::forPost($ID);
$values = $meta->getAll([
'post_title',
'_square_catalog_id',
@@ -194,18 +194,17 @@
?>
<div class="menu-item<?= !empty($variations) ? ' variable' : '' ?>" data-section="<?=$slug?>">
- <div class="header row btw">
+ <div class="header row x-btw">
<h3><?= $values['post_title']?></h3>
<p class="price"><?= $priceRange ?></p>
</div>
<div class="description">
- <?php $meta->render('render', 'post_excerpt')?>
+ <?= Render::renderFrom($meta, 'post_excerpt')?>
</div>
- <div class="info row end">
+ <div class="info row right">
<?php
if (empty($variations)) {
- $meta->render(
- 'form',
+ Form::renderFrom($meta,
$ID.'|cart_quantity',
[
'type' => 'number',
@@ -229,8 +228,7 @@
foreach ($variations as $index =>$row) {
jvbDump($index, 'index');
jvbDump($row, 'row');
- $meta->render(
- 'form',
+ Form::renderFrom($meta,
'quantity-'.$index,
[
'type' => 'number',
--
Gitblit v1.10.0