From 32ce5c542c90be348895328078e392dde2052957 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 04 Sep 2026 19:15:16 +0000
Subject: [PATCH] =Working at adding defined fields to a dedicated panel in the gutenberg editor. Registrar now has AddCustomFields.php, which currently only supports post fields. Added a @wordpress/plugins base _meta/fields in /build and /src that successfully creates a panel. Next steps: determine sections and fields, group fields by section (each section to a panel), and save output

---
 inc/blocks/CustomBlocks.php |   54 +++++++++++++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 25 deletions(-)

diff --git a/inc/blocks/CustomBlocks.php b/inc/blocks/CustomBlocks.php
index 9d77437..7650d91 100644
--- a/inc/blocks/CustomBlocks.php
+++ b/inc/blocks/CustomBlocks.php
@@ -1,14 +1,12 @@
 <?php
 namespace JVBase\blocks;
 
-use DateTime;
 use DOMDocument;
+use JVBase\Instance;
 use JVBase\managers\Cache;
-use JVBase\managers\LoginManager;
+use JVBase\managers\Login;
 use JVBase\managers\SEO\BreadcrumbManager;
-use JVBase\managers\SEO\render\Thing\CreativeWork\MediaObject\VideoObject;
 use JVBase\utility\Image;
-use JVBase\utility\Video;
 use WP_Block;
 use WP_Query;
 
@@ -18,6 +16,7 @@
 
 class CustomBlocks
 {
+	use Instance;
     protected Cache $cache;
 
 	protected static ?WP_Query $currentLoop = null;
@@ -31,11 +30,10 @@
 	protected static array $pendingClass = [];
 	protected static bool $renderGallery = false;
 
-    public function __construct()
+    private function __construct()
     {
-        $this->cache = Cache::for('blocks', WEEK_IN_SECONDS);
-		$this->cache->connect('post')->connect('taxonomy');
-		$this->cache->flush();
+//        $this->cache = Cache::for('blocks', null,WEEK_IN_SECONDS);
+
 		add_filter('pre_render_block', [$this, 'prerender'], 10, 3);
 		add_filter('render_block', [$this, 'render'], 10, 2);
 
@@ -114,6 +112,10 @@
 	{
 		$blockName = $this->sanitizeBlockName($block);
 
+		if (str_starts_with($blockName, 'woocommerce') ) {
+			return $content;
+		}
+
 		$base = ($isPrerender) ? 'prerender_' : 'render_';
 		$method = $base.$blockName;
 		$function = BASE.$method;
@@ -124,7 +126,7 @@
 			$content = $this->$method($block, $content, $parent);
 			return $isPrerender ? $this->maybeOutputCustomStyles().$content : $content;
 		} elseif (JVB_TESTING && !empty($blockName)) {
-			if (!in_array($block['blockName'], $this->getIgnore($isPrerender))) {
+			if (!str_starts_with($block['blockName'],'jvb/') && !in_array($block['blockName'], $this->getIgnore($isPrerender))) {
 				jvbDump('No method found for '.print_r($block['blockName'], true));
 			}
 		}
@@ -135,6 +137,7 @@
 			//Ignore for both
 			$base = [
 				'core/null',
+				'core/pattern',
 				'core/list-item',
 				'core/post-content',
 				'jvb/drawer-menu',
@@ -166,8 +169,7 @@
 		}
 	public function prerender(?string $content, array $block, ?WP_Block $parent = null):?string
 	{
-		$result = $this->checkMethods($content, $block, $parent, true);
-		return $result;
+		return $this->checkMethods($content, $block, $parent, true);
 	}
 
     public function render(string $content, array $block):string
@@ -180,13 +182,12 @@
 				wp_enqueue_style('jvb-form');
 				break;
 			case 'jvb/timeline':
+			case 'jvb/menu':
 				wp_enqueue_script('jvb-gallery');
 				add_action('wp_footer', 'jvbRenderGallery');
 				break;
 		}
 
-
-
 		return $this->checkMethods($content, $block);
     }
 
@@ -552,7 +553,7 @@
 		}
 		if (array_key_exists('focalPoint', $attrs)) {
 			$attrs['isObjectPosition'] = true;
-			$style = $this->getFocalPointStyle($attrs['focalPoint'], $attrs);
+			$style = implode(';',$this->getFocalPointStyle($attrs['focalPoint'], $attrs));
 			$style .= ';object-fit:none;';
 			$imgLink = str_replace('<img', sprintf(
 				'<img style="%s"',
@@ -820,8 +821,8 @@
 		}
 
 		if (array_key_exists('displayLoginAsForm', $attrs) && $attrs['displayLoginAsForm']) {
-			LoginManager::getInstance()->setAction($action);
-			return LoginManager::getInstance()->renderLoginForm($action, $redirect, '<h2>Login</h2>');
+			Login::getInstance()->setAction($action);
+			return Login::getInstance()->renderLoginForm($action, $redirect, '<h2>Login</h2>');
 
 		}
 
@@ -1403,9 +1404,6 @@
 
 		if (!static::$currentLoop) {
 
-			if (JVB_TESTING) {
-				jvbDump('No loop stored');
-			}
 			return $content;
 		}
 		if (static::$currentLoop->have_posts()) {
@@ -1941,9 +1939,7 @@
 			);
 
 		}
-		if (JVB_TESTING) {
-			jvbDump('Could not create template part block for '.$block['blockName']);
-		}
+
 		return $content;
 
 //		$isHeaderTemplate = (
@@ -2309,6 +2305,10 @@
 		), jvbSearch($placeholder, uniqid(), $label, $buttonText, $isInside, $hideInput));
 	}
     //core_shortcode
+	public function prerender_core_shortcode(array $block, ?string $content, ?WP_Block $parent):?string
+	{
+		return do_shortcode($block['innerHTML']??'');
+	}
 	public function prerender_core_social_link(array $block, ?string $content, ?WP_Block $parent):?string
 	{
 //		jvbDump($block, 'social link');
@@ -2452,7 +2452,6 @@
 		}
 		$content = '';
 		foreach ($block['innerBlocks'] as $b) {
-
 			$rendered = $parent
 				? $this->checkMethods(null, $b, $parent, true)
 				: render_block($b);
@@ -2790,6 +2789,9 @@
 					);
 				}
 				return $classes;
+			case 'anchor':
+				//TODO: What's this doing?
+				return '';
             default:
 				if (JVB_TESTING && !is_admin() &&!in_array($key, $this->ignore)) {
 //					TESTING
@@ -3152,7 +3154,9 @@
 					break;
 				}
 				return $this->getColorStyle($value, $type);
-
+			case 'anchor':
+				//TODO: What should we do here?
+				break;
             // Any other attributes that need direct styling
             default:
 				if (JVB_TESTING && !is_admin() && !in_array($key, $this->ignore)) {
@@ -3182,7 +3186,7 @@
 						break;
 					default:
 						if (JVB_TESTING) {
-							jvbDump($value, 'No preset found for size: '.print_r($value, true));
+							error_log('No preset found for size: '.print_r($value, true));
 						}
 				}
 			}

--
Gitblit v1.10.0