From 4089ba01e0881c89a72332e13bc3a80b6bddec2a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Mon, 29 Jun 2026 22:15:55 +0000
Subject: [PATCH] =DashboardManager overhaul. A bit easier to modify the output of pages. Still have to get the account pages to work as expected, as well as verify the integrations and others are working - but registrar/content pages work as expected. Also fixed up the table generation in CRUD.js and CRUDSkeleton.php

---
 inc/registrar/config/seo/Schema.php |   98 ++++++++++++++++++++++++------------------------
 1 files changed, 49 insertions(+), 49 deletions(-)

diff --git a/inc/registrar/config/seo/Schema.php b/inc/registrar/config/seo/Schema.php
index 0214fa5..6692c5e 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();
 	}
@@ -90,49 +93,8 @@
 		add_action('wp_head', [$this, 'outputSchema'], 1);
 		add_filter('the_seo_framework_schema_graph_data', [$this, 'filterTSFSchema'], 10, 2);
 		add_filter('the_seo_framework_title_from_custom_field', [$this, 'filterTSFOGTitle'], 10, 2);
-
-		$this->maybeExcludeSingles();
 	}
-		protected function maybeExcludeSingles(): void
-		{
-			$exclude = $this->cache->remember(
-				'excludeSingles',
-				function () {
-					$exclude = [];
-					$registrar = Registrar::getInstance($this->slug);
-					if ($registrar && $registrar->hasFeature('hide_single')) {
-						$exclude = $this->excludeSingle();
-					}
-					if ($registrar && $registrar->hasFeature('is_timeline')) {
-						$exclude = array_merge($exclude, $this->excludeTimeline());
-					}
-					return $exclude;
-				}
-			);
 
-			if (!empty($exclude)) {
-				add_filter('the_seo_framework_sitemap_exclude_ids', $exclude);
-			}
-		}
-		protected function excludeSingle():array
-		{
-			return get_posts([
-				'post_type'		=> jvbCheckBase($this->slug),
-				'posts_per_page'=> -1,
-				'fields'		=> 'ids',
-				'post_status'	=> 'publish',
-			]);
-		}
-		protected function excludeTimeline():array
-		{
-			return get_posts([
-				'post_type'		=> jvbCheckBase($this->slug),
-				'posts_per_page'=> -1,
-				'fields'		=> 'ids',
-				'post_status'	=> 'publish',
-				'post_parent__not_in'	=> [0], // Only get posts with a parent
-			]);
-		}
 	public function filterTSFSchema(array $graph, ?array $args):array
 	{
 		$based = jvbCheckBase($this->slug);
@@ -181,7 +143,10 @@
 					$config = $this->getConfig();
 
 					$class = JVB()->schemaHelper()::classFromConfig($config, $meta);
-					$class->setAuthor(JVB()->seo()->getCreator(true));
+					if (property_exists($class, 'author')) {
+						$class->setAuthor(JVB()->seo()->getCreator(true));
+					}
+
 
 					$class = apply_filters('jvb_single_'.$this->slug.'_schema_output', $class, $ID);
 					return $class->outputSchema();
@@ -243,11 +208,16 @@
 			if (JVB_TESTING){
 				$this->archiveCache->flush();
 			}
-
+			$this->archiveCache->flush();
 			return $this->archiveCache->remember(
 				$this->slug,
 				function() {
+
 					$action = BASE.ucfirst($this->slug).'Archive';
+					$override = apply_filters($action.'Override', []);
+					if (!empty($override)) {
+						return $override;
+					}
 					$config = JVB()->schemaHelper()->archive($this->slug);
 					if (!array_key_exists('type', $config)) {
 						$config['type'] = 'JVBase\inc\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage\CollectionPage';
@@ -274,7 +244,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'
@@ -295,7 +265,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;
 				}
 			);
@@ -310,6 +284,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);
@@ -326,7 +307,10 @@
 				}
 				$config = $this->getConfig();
 				$class = JVB()->schemaHelper()::classFromConfig($config, $meta);
-				$class->delete('about');
+				if ($class) {
+					$class->delete('about');
+				}
+
 
 				switch ($type) {
 					case 'post':
@@ -351,8 +335,6 @@
 			error_log('[SEO]Schema::getConfig Invalid type: '.$type);
 			return [];
 		}
-		jvbDump($this->slug);
-		jvbDump($type);
 		return JVB()->schemaHelper()::getConfig($this->slug, $type);
 	}
 
@@ -442,7 +424,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());
@@ -472,9 +454,11 @@
 				'type'	=> 'JVBase\inc\managers\SEO\render\Thing\CreativeWork\Comment\Answer',
 				'text'	=> wp_strip_all_tags(str_replace("\n", '', $meta->get('post_content'))),
 			],
+			'answerCount'	=> 1,
 		];
 		$question = SchemaHelper::classFromConfig($question);
 		$page->setMainEntity($question);
+
 		$page->setAuthor(JVB()->seo()->getCreator(true));
 		return $page->outputSchema();
 
@@ -658,4 +642,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