From ba1e1ccf869b818f7a7a897264dfea05563a7796 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 07 Jun 2026 20:10:20 +0000
Subject: [PATCH] =Major overhaul of Integrations. Playing around with adding fields to post types through Registrar from an integrations' class file.

---
 inc/registrar/config/seo/Resolver.php |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/inc/registrar/config/seo/Resolver.php b/inc/registrar/config/seo/Resolver.php
index db40ea7..172e1c5 100644
--- a/inc/registrar/config/seo/Resolver.php
+++ b/inc/registrar/config/seo/Resolver.php
@@ -15,7 +15,7 @@
 class Resolver {
 	protected static ?Meta $meta;
 
-	public static function resolve(string $template, ?Meta $meta): string
+	public static function resolve(string $template, ?Meta $meta): string|array|\JVBase\managers\SEO\render\Thing\Thing
 	{
 		if (!$meta) {
 			if (is_singular()){
@@ -25,6 +25,11 @@
 			}
 		}
 		self::$meta = $meta;
+
+		if (preg_match('/^\{\{([^}]+)}}$/', trim($template), $matches)) {
+			return self::resolveVariable($matches[1], $meta);
+		}
+
 		return preg_replace_callback(
 			'/\{\{([^}]+)}}/',
 			fn($matches) => self::resolveVariable($matches[1], $meta),
@@ -34,6 +39,7 @@
 	protected static function resolveVariable(string $variable, ?Meta $meta = null): mixed
 	{
 		$variable = trim($variable);
+
 		switch ($variable) {
 			case 'CREATOR':
 				return JVB()->seo()->getCreator();
@@ -50,6 +56,10 @@
 		if (str_contains($variable, '.') && $meta) {
 			return self::resolveRelation($variable, $meta);
 		}
+		$function = BASE.'resolve_'.$variable;
+		if (function_exists($function)) {
+			return $function($variable, $meta);
+		}
 		if ($meta && $variable === 'post_permalink') {
 			return get_the_permalink($meta->id());
 		}
@@ -78,7 +88,6 @@
 		$relation = array_shift($parts);
 		$field = implode('.', $parts);
 
-
 		//We need to:
 			// 1) Get the id of the item we're fetching (meta value of the $relation)
 		if ($relation === 'registrar') {
@@ -94,6 +103,7 @@
 		if (!$meta) {
 			return'';
 		}
+
 		$ID = $meta->get($relation);
 		if (empty($ID)) {
 			return '';
@@ -172,7 +182,7 @@
 
 		$ignore = ['description', 'name'];
 		if (JVB_TESTING && !in_array($property, $ignore)) {
-			error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
+//			error_log('[SEO]Resolver - No method found for '.$property.' with value: '.print_r($value, true).'. Defaulting to base Resolver');
 		}
 
 
@@ -199,6 +209,12 @@
 			if (!$imgID || $imgID === '') {
 				return null;
 			}
+
+			return self::imgIDToSchema($imgID);
+
+		}
+		public static function imgIDToSchema(int $imgID):ImageObject|null
+		{
 			$img = wp_get_attachment_image_src($imgID,'full');
 			if (!$img) {
 				return null;
@@ -213,12 +229,14 @@
 					$imageObject = new ImageObject();
 					$imageObject->setContentUrl($img[0]);
 					$width = new QuantitativeValue();
+					$width->showID(false);
 					$width->setValue($img[1]);
 					$width->setUnitText('px');
 					$imageObject->setWidth($width);
 					$height = new QuantitativeValue();
+					$height->showID(false);
 					$height->setValue($img[2]);
-					$width->setUnitText('px');
+					$height->setUnitText('px');
 					$imageObject->setHeight($height);
 
 					$image_path = get_attached_file($imgID);
@@ -239,7 +257,6 @@
 					return $imageObject;
 				}
 			);
-
 		}
 
 		public static function resolveCreator(string $type, mixed $value, mixed $schema, ?Meta $meta):mixed

--
Gitblit v1.10.0