From 275c0d74cd68677622a5431505c5c870c473063d Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 29 Mar 2026 21:40:15 +0000
Subject: [PATCH] =Seems to be working, huzzah! Added some changes for on-this-page nav
---
inc/registrar/config/seo/Schema.php | 52 +++++++++++++---------------------------------------
1 files changed, 13 insertions(+), 39 deletions(-)
diff --git a/inc/registrar/config/seo/Schema.php b/inc/registrar/config/seo/Schema.php
index b48b8de..5144fd2 100644
--- a/inc/registrar/config/seo/Schema.php
+++ b/inc/registrar/config/seo/Schema.php
@@ -169,7 +169,7 @@
$meta = Meta::forPost($ID);
$config = $this->getConfig();
- $class = $this->classFromConfig($config, $meta);
+ $class = JVB()->schemaHelper()::classFromConfig($config, $meta);
$class->setAuthor(JVB()->seo()->getCreator(true));
return $class->outputSchema();
@@ -188,7 +188,8 @@
$ID,
function() use ($ID) {
$action = BASE.ucfirst($this->slug).'Schema';
- $config = get_option($action, apply_filters($action, $this->defaultSchema));
+ $config = JVB()->schemaHelper()::schema($action);
+
if (!array_key_exists('type', $config)) {
$config['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage';
}
@@ -196,7 +197,7 @@
error_log('No class found for archive schema output: '.$config['type']);
return [];
}
- $class = $this->classFromConfig($config);
+ $class = JVB()->schemaHelper()::classFromConfig($config);
$class->setIsPartOf(get_home_url().'/#website');
$itemList = new render\Thing\Intangible\ItemList\ItemList();
@@ -235,7 +236,7 @@
$this->slug,
function() {
$action = BASE.ucfirst($this->slug).'Archive';
- $config = get_option($action, apply_filters($action, $this->defaultArchive));
+ $config = JVB()->schemaHelper()->archive($this->slug);
if (!array_key_exists('type', $config)) {
$config['type'] = 'JVBase\managers\SEO\render\Thing\CreativeWork\WebPage\CollectionPage';
}
@@ -246,7 +247,7 @@
$obj = get_queried_object();
$meta = (property_exists($obj, 'taxonomy')) ? Meta::forTerm($obj->term_id) : null;
- $class = $this->classFromConfig($config, $meta);
+ $class = JVB()->schemaHelper()::classFromConfig($config, $meta);
$class->setIsPartOf(get_home_url().'/#website');
$itemList = new render\Thing\Intangible\ItemList\ItemList();
@@ -301,7 +302,7 @@
$meta = null;
}
$config = $this->getConfig('archive');
- $class = $this->classFromConfig($config, $meta);
+ $class = JVB()->schemaHelper()::classFromConfig($config, $meta);
$class->delete('about');
switch ($type) {
@@ -327,9 +328,7 @@
error_log('[SEO]Schema::getConfig Invalid type: '.$type);
return [];
}
- $action = BASE.ucfirst($this->slug).ucfirst($type);
- $default = 'default'.ucfirst($type);
- return get_option($action, apply_filters($action, $this->$default));
+ return JVB()->schemaHelper()::getConfig($this->slug, $type);
}
public function define(string $property, string $value):void
@@ -394,39 +393,14 @@
$config = $this->getConfig('meta');
$meta = Meta::forPost(get_the_ID());
$title = Resolver::resolve($config['name'], $meta);
- } elseif (is_post_type_archive($based) || is_tax($based)) {
+ } elseif (is_post_type_archive($based) ) {
$config = $this->getConfig('archive');
$title = $config['name'];
+ } elseif (is_tax($based)) {
+ $config = $this->getConfig('archive');
+ $meta = Meta::forTerm(get_queried_object_id());
+ $title = Resolver::resolve($config['name'], $meta);
}
return $title;
}
-
- protected function classFromConfig(array $config, ?Meta $meta = null):mixed
- {
- if (!array_key_exists('type', $config)) {
- error_log('[Schema]::classFromConfig No class defined in config: '.print_r($config, true));
- return false;
- }
- $className = $config['type'];
- unset($config['type']);
- $class = new $className();
-
- foreach ($config as $property=>$value) {
- if (is_array ($value)) {
- $value = $this->classFromConfig($value, $meta);
- }
- $method = 'set'.ucfirst($property);
- if (!method_exists($class, $method)) {
- error_log('[Schema]::classFromConfig - method: '.$method.' does not exist in class: '.$className);
- continue;
- }
- if (is_string($value) && str_contains($value, '{{')) {
- $value = Resolver::resolveForSchema($property, $value, $config, $meta);
- }
- if (!empty($value)) {
- $class->$method($value);
- }
- }
- return $class;
- }
}
--
Gitblit v1.10.0