From 266aa37c48222993bf7bdad6834e31bd08736f5e Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 23 May 2026 21:22:07 +0000
Subject: [PATCH] =Post type archive meta title fix

---
 inc/registrar/config/seo/Resolver.php          |    7 +++
 inc/blocks/CustomBlocks.php                    |   34 +++++++++++------
 inc/registrar/config/seo/Meta.php              |    2 +
 inc/managers/SEO/render/SchemaOutput.php       |    6 +-
 inc/managers/SEO/BreadcrumbManager.php         |    3 +
 base/SchemaHelper.php                          |    1 
 inc/registrar/config/seo/Schema.php            |    7 ++-
 inc/managers/SEO/render/Traits/ThingSchema.php |    2 
 8 files changed, 43 insertions(+), 19 deletions(-)

diff --git a/base/SchemaHelper.php b/base/SchemaHelper.php
index 6a329d5..ac83573 100644
--- a/base/SchemaHelper.php
+++ b/base/SchemaHelper.php
@@ -125,6 +125,7 @@
 			default => [],
 		};
 
+
 		$result = apply_filters(BASE.ucfirst($type).ucfirst($format).'Default', $defaults);
 		if ($format === 'reference' && empty($result)) {
 			$full = self::getDefault($type, 'schema');
diff --git a/inc/blocks/CustomBlocks.php b/inc/blocks/CustomBlocks.php
index 0a9cc31..fc8fe8f 100644
--- a/inc/blocks/CustomBlocks.php
+++ b/inc/blocks/CustomBlocks.php
@@ -102,7 +102,7 @@
 		} else if (method_exists($this, $method)) {
 			$content = $this->$method($block, $content, $parent);
 			return $isPrerender ? $this->maybeOutputCustomStyles().$content : $content;
-		} elseif (!empty($blockName) && JVB_TESTING) {
+		} elseif (JVB_TESTING && !empty($blockName)) {
 			if (!in_array($block['blockName'], $this->getIgnore($isPrerender))) {
 				jvbDump('No method found for '.print_r($block['blockName'], true));
 			}
@@ -231,7 +231,7 @@
 
     public function prerender_core_columns(array $block, ?string $content, ?WP_Block $parent):?string
     {
-		jvbDump($block, 'columns');
+//		jvbDump($block, 'columns');
 		$attrs = $block['attrs']??[];
 		$tagName = array_key_exists('tagName', $attrs) ? $attrs['tagName'] : 'section';
 
@@ -654,7 +654,7 @@
 
     public function prerender_core_paragraph(array $block, ?string $content, ?WP_Block $parent):?string
     {
-		jvbDump($block, 'paragraph');
+//		jvbDump($block, 'paragraph');
 //		jvbDump($parent, 'Parent');
 		$inside = $this->inside($block);
         return empty($inside) ? '' : sprintf(
@@ -1359,7 +1359,10 @@
 		$inner = '';
 
 		if (!static::$currentLoop) {
-			jvbDump('No loop stored');
+
+			if (JVB_TESTING) {
+				jvbDump('No loop stored');
+			}
 			return $content;
 		}
 		if (static::$currentLoop->have_posts()) {
@@ -1799,7 +1802,7 @@
 
 	public function prerender_core_query_title(array $block, ?string $content, ?WP_Block $parent):?string
 	{
-		jvbDump($block, 'query title');
+//		jvbDump($block, 'query title');
 		$attr = $block['attrs'];
 		$name = '';
 		$showPrefix = $attr['showPrefix']??false;
@@ -1952,7 +1955,7 @@
     //core_archives
 	public function render_core_archives(array $block, string $content):string
 	{
-		jvbDump($block, 'archives');
+//		jvbDump($block, 'archives');
 		$attrs = $block['attrs']??[];
 		$isDropdown = $this->checkAttrs('displayAsDropdown', $attrs);
 
@@ -2214,7 +2217,6 @@
 		}
 		$inside = [];
 		foreach($pages->posts as $page) {
-			jvbDump($page);
 			$inside[] = sprintf(
 				'<li><a href="%s">%s</a>',
 				get_the_permalink($page->ID),
@@ -3209,7 +3211,10 @@
 							$styles['color'] = $this->getColor($v['text']);
 						}
 						if (isset($v['gradient'])) {
-							jvbDump($v, 'Gradient');
+
+							if (JVB_TESTING) {
+								jvbDump($v, 'Gradient');
+							}
 						}
 						break;
 
@@ -3279,7 +3284,9 @@
 							if ($sk === 'minHeight') {
 								$styles['min-height'] = $sv;
 							} else {
-								jvbDump('No config set for dimension '.$sk.': '.print_r($sv, true));
+								if (JVB_TESTING) {
+									jvbDump('No config set for dimension '.$sk.': '.print_r($sv, true));
+								}
 							}
 						}
 
@@ -3340,7 +3347,7 @@
 					unset($border['style']);
 					unset($border['color']);
 					if (!empty($border)) {
-						jvbDump($border,'[getBorderStyle] Leftover styles:');
+						jvbDump($border, '[getBorderStyle] Leftover styles:');
 					}
 				}
 
@@ -3443,8 +3450,11 @@
 						}, $selectors);
 						$fullSelector = implode(',', $fullSelector);
 
-						jvbDump($state, 'state');
-						jvbDump($rules, 'rules');
+
+						if (JVB_TESTING) {
+							jvbDump($state, 'state');
+							jvbDump($rules, 'rules');
+						}
 
 						if (isset($rules['color']['text']) || isset($rules['text'])) {
 							$css['color'] = $this->getColor($rules['color']['text'] ?? $rules['text']);
diff --git a/inc/managers/SEO/BreadcrumbManager.php b/inc/managers/SEO/BreadcrumbManager.php
index 224569f..299d396 100644
--- a/inc/managers/SEO/BreadcrumbManager.php
+++ b/inc/managers/SEO/BreadcrumbManager.php
@@ -224,7 +224,7 @@
 
 		$registrar = Registrar::getInstance($name);
 
-		if($registrar && $registrar->hasFeature('show_directory')) {
+		if($registrar && $registrar->hasFeature('show_directory') && JVB()->directories()) {
 			$directory = JVB()->directories();
 			if ($directory && !empty($directory->directories($name)??[])){
 				$crumbs[] = [
@@ -233,6 +233,7 @@
 				];
 			}
 		} elseif (Site::has('is_directory') && $name === 'directory') {
+
 			$crumbs[] = [
 				'name'	=> JVB()->directories()->referAs(true),
 				'url'	=> get_post_type_archive_link($type)
diff --git a/inc/managers/SEO/render/SchemaOutput.php b/inc/managers/SEO/render/SchemaOutput.php
index 4619d94..a18a09f 100644
--- a/inc/managers/SEO/render/SchemaOutput.php
+++ b/inc/managers/SEO/render/SchemaOutput.php
@@ -39,7 +39,7 @@
 				$schema[] = $seo->schema()->outputSingularSchema();
 			}
 		}elseif (is_post_type_archive($this->types)) {
-			error_log('It is a post type archive');
+
 			$type = get_queried_object();
 			$type = $type->name;
 			$registrar = Registrar::getInstance($type);
@@ -62,9 +62,9 @@
 			return intval(get_option(BASE.$item.'_archive', false));
 		},Registrar::getFeatured('is_content', 'term'))));
 
-		if (is_page($isContent)){
+		if (!empty($isContent) && is_page($isContent)){
 			$type = get_post_meta(get_the_id(), BASE.'for_type', true);
-			error_log('Type: '.print_r($type, true));
+//			error_log('Type: '.print_r($type, true));
 			if (!empty($type)) {
 				$registrar = Registrar::getInstance($type);
 				if ($registrar) {
diff --git a/inc/managers/SEO/render/Traits/ThingSchema.php b/inc/managers/SEO/render/Traits/ThingSchema.php
index 7124007..3d0b14b 100644
--- a/inc/managers/SEO/render/Traits/ThingSchema.php
+++ b/inc/managers/SEO/render/Traits/ThingSchema.php
@@ -65,7 +65,7 @@
 					$value = $value->getTime();
 				}else if (!is_string($value)) {
 					if (JVB_TESTING && !is_numeric($value)) {
-						error_log('Normal value? '.print_r($value, true));
+//						error_log('Normal value? '.print_r($value, true));
 					}
 				}
 
diff --git a/inc/registrar/config/seo/Meta.php b/inc/registrar/config/seo/Meta.php
index 4ab4021..7e34b0b 100644
--- a/inc/registrar/config/seo/Meta.php
+++ b/inc/registrar/config/seo/Meta.php
@@ -55,11 +55,13 @@
 
 	public function filterTitle(string $title, ?array $args): string
 	{
+		error_log('Filtering title...');
 		if (jvbTSFDoIt($this->slug, $args)){
 			return $title;
 		}
 		$ID = jvbTSFGetID($args);
 
+
 		$meta = new \JVBase\meta\Meta($ID, Registrar::getInstance($this->slug)->getType());
 		return Resolver::resolve($this->title, $meta);
 	}
diff --git a/inc/registrar/config/seo/Resolver.php b/inc/registrar/config/seo/Resolver.php
index 3cf1271..918d7a3 100644
--- a/inc/registrar/config/seo/Resolver.php
+++ b/inc/registrar/config/seo/Resolver.php
@@ -36,6 +36,13 @@
 		switch ($variable) {
 			case 'CREATOR':
 				return JVB()->seo()->getCreator();
+			case 'name':
+				if (is_post_type_archive()) {
+					$obj = get_queried_object();
+
+					$registrar = Registrar::getInstance($obj->name);
+					return $registrar ? $registrar->getPlural() : $obj->label;
+				}
 				break;
 		}
 		if (str_contains($variable, '.')) {
diff --git a/inc/registrar/config/seo/Schema.php b/inc/registrar/config/seo/Schema.php
index 85ec62d..6b01794 100644
--- a/inc/registrar/config/seo/Schema.php
+++ b/inc/registrar/config/seo/Schema.php
@@ -295,7 +295,10 @@
 					$class->setMainEntity($itemList);
 
 					$schema = $class->outputSchema();
-					error_log('Generated archive schema: '.print_r($schema, true));
+					if (JVB_TESTING) {
+//						error_log('Generated archive schema: '.print_r($schema, true));
+					}
+
 					return $schema;
 				}
 			);
@@ -440,7 +443,7 @@
 			$title = Resolver::resolve($config['name']??$config['title']??'', $meta);
 		} elseif (is_post_type_archive($based) ) {
 			$config = $this->getConfig('archive');
-			$title = $config['name'];
+			$title = Resolver::resolve($config['name'], null);
 		} elseif (is_tax($based)) {
 			$config = $this->getConfig('archive');
 			$meta = Meta::forTerm(get_queried_object_id());

--
Gitblit v1.10.0