From 3b83905603d44b1a08f8b2b36a605808ce686ad6 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 02 Jun 2026 00:46:48 +0000
Subject: [PATCH] =double checking schema outputs for legacytattooremoval

---
 inc/registrar/config/seo/Schema.php |   48 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/inc/registrar/config/seo/Schema.php b/inc/registrar/config/seo/Schema.php
index 15c256e..c9e83e5 100644
--- a/inc/registrar/config/seo/Schema.php
+++ b/inc/registrar/config/seo/Schema.php
@@ -23,6 +23,7 @@
 
 	protected array $properties = [];
 	protected array $referenceProperties = [];
+	protected array $extras = [];
 	protected array $defaultReference = [
 		'name'	=> '{{post_title}}',
 		'url'	=> '{{post_permalink}}',
@@ -67,6 +68,8 @@
 			}
 			$this->defaultArchive['description'] = '{{registrar.'.$slug.'.description}}';
 		}
+
+		$this->extras = apply_filters(BASE.ucfirst($slug).'Extras', []);
 		$this->initFilters();
 		$this->registerHooks();
 	}
@@ -181,8 +184,9 @@
 					$config = $this->getConfig();
 
 					$class = JVB()->schemaHelper()::classFromConfig($config, $meta);
-
 					$class->setAuthor(JVB()->seo()->getCreator(true));
+
+					$class = apply_filters('jvb_single_'.$this->slug.'_schema_output', $class, $ID);
 					return $class->outputSchema();
 				}
 			);
@@ -273,7 +277,7 @@
 					$class->setIsPartOf(get_home_url().'/#website');
 					$itemList = new render\Thing\Intangible\ItemList\ItemList();
 					$items = new WP_Query([
-						'post_type'		=> jvbCheckBase($this->slug),
+						'post_type'		=> $registrar->getBased(),
 						'posts_per_page'=> 25,
 						'post_status'	=> 'publish',
 						'fields'		=> 'ids'
@@ -294,7 +298,11 @@
 					$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;
 				}
 			);
@@ -309,6 +317,13 @@
 		$cached = $this->referenceCache->remember(
 			$ID,
 			function () use ($ID, $type) {
+
+				$postType = get_post_type($ID);
+				$function = BASE.'build_singular_'.jvbNoBase($postType).'_schema_reference';
+
+				if (function_exists($function)) {
+					return $function($ID);
+				}
 				switch ($type) {
 					case 'post':
 						$meta = Meta::forPost($ID);
@@ -325,7 +340,10 @@
 				}
 				$config = $this->getConfig();
 				$class = JVB()->schemaHelper()::classFromConfig($config, $meta);
-				$class->delete('about');
+				if ($class) {
+					$class->delete('about');
+				}
+
 
 				switch ($type) {
 					case 'post':
@@ -399,7 +417,7 @@
 			$config['type'] = $this->defaultSchema['type'];
 			update_option(BASE.ucfirst($this->slug).'Schema', $config);
 		}
-		$class = $this->getConfig()['type'];
+		$class = $config['type'];
 		if (!class_exists($class)) {
 			error_log('[SEO]Schema::defineReference Class not found: '.$class);
 			return;
@@ -436,10 +454,10 @@
 		if (is_singular($based)){
 			$config = $this->getConfig('meta');
 			$meta = Meta::forPost(get_the_ID());
-			$title = Resolver::resolve($config['name']??$config['title'], $meta);
+			$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());
@@ -655,4 +673,20 @@
 		$page->setMainEntity($termset);
 		return $page->outputSchema();
 	}
+
+	public function extra():array
+	{
+		if (empty($this->extras)) {
+			return [];
+		}
+		$out = [];
+		foreach ($this->extras as $config) {
+			$schema = SchemaHelper::classFromConfig($config);
+			$output = $schema->outputSchema();
+			if (!empty($output)) {
+				$out[] = $output;
+			}
+		}
+		return $out;
+	}
 }

--
Gitblit v1.10.0