From c4aa5cdb5e90ad4b420e22772797d16980232a2b Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 15 Apr 2026 18:38:55 +0000
Subject: [PATCH] =Updating custom tables to utilize CustomTable.php
---
inc/registrar/config/seo/Resolver.php | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/inc/registrar/config/seo/Resolver.php b/inc/registrar/config/seo/Resolver.php
index 3f18043..ab46dd4 100644
--- a/inc/registrar/config/seo/Resolver.php
+++ b/inc/registrar/config/seo/Resolver.php
@@ -16,6 +16,13 @@
public static function resolve(string $template, ?Meta $meta): string
{
+ if (!$meta) {
+ if (is_singular()){
+ $meta = Meta::forPost(get_the_ID());
+ }else if (is_tax()) {
+ $meta = Meta::forTerm(get_queried_object()->term_id);
+ }
+ }
self::$meta = $meta;
return preg_replace_callback(
'/\{\{([^}]+)}}/',
@@ -45,6 +52,9 @@
error_log('[SEO]Meta Resolver. Could not find meta configuration for variable: '.$variable);
return '';
}
+ if ($variable === 'post_content') {
+ return self::resolvePostContent($variable, $meta);
+ }
return match($config['type']) {
'upload', 'image', 'gallery' => self::resolveImage($variable, $meta),
'selector', 'taxonomy', 'user', 'post' => self::resolveObject($variable, $meta),
@@ -69,6 +79,8 @@
}
}
+ error_log('resolveRelation: '.print_r($path, true));
+
$ID = $meta->get($relation);
if (!$ID || $ID === '') {
return '';
@@ -78,14 +90,16 @@
if (!$config) {
return '';
}
+
$type = false;
if ($config['type'] === 'taxonomy' || array_key_exists('taxonomy', $config)) {
- $type = 'taxonomy';
- } elseif ($config['type'] === 'user'){
+ $type = 'term';
+ } elseif ($config['type'] === 'user' || array_key_exists('user', $config)){
$type = 'user';
- } elseif ($config['type'] === 'post'){
+ } elseif ($config['type'] === 'post' || array_key_exists('post', $config)){
$type = 'post';
}
+
if (!$type) {
error_log('[SEO]Meta Resolver. Could not find type for relation: '.$relation.': '.$field);
return '';
@@ -95,6 +109,9 @@
return self::resolve($field, $newMeta);
}
+ protected static function resolvePostContent(string $variable, ?Meta $meta):string{
+ return wp_strip_all_tags(str_replace("\n", '', $meta->get('post_content')));
+ }
protected static function resolveImage(string $variable, ?Meta $meta, bool $returnID = false): string
{
$imgID = $meta->get($variable);
@@ -133,7 +150,11 @@
return $checkType;
}
- error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
+ $ignore = ['description', 'name'];
+ if (!in_array($property, $ignore)) {
+ error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
+ }
+
return self::resolve($value, $meta);
}
--
Gitblit v1.10.0