From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.

---
 inc/managers/SEO/TemplateResolver.php |   59 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/inc/managers/SEO/TemplateResolver.php b/inc/managers/SEO/TemplateResolver.php
index cda61ed..bae31b9 100644
--- a/inc/managers/SEO/TemplateResolver.php
+++ b/inc/managers/SEO/TemplateResolver.php
@@ -2,6 +2,7 @@
 namespace JVBase\managers\SEO;
 
 use JVBase\meta\Meta;
+use JVBase\registrar\Registrar;
 use WP_Post;
 use WP_Term;
 use WP_User;
@@ -187,14 +188,14 @@
 	 */
 	private function isRelatedPostsField(string $fieldName): bool
 	{
-		if (!defined('JVB_CONTENT')) {
+		$posts = Registrar::getRegistered('post');
+		if (empty($posts)) {
 			return false;
 		}
 
-		// Check if field name matches any plural content type
-		foreach (JVB_CONTENT as $type => $config) {
-			$plural = strtolower($config['plural'] ?? '');
-			if ($plural && $fieldName === $plural) {
+		foreach ($posts as $post) {
+			$registrar = Registrar::getInstance($post);
+			if ($registrar && strtolower($registrar->getPlural()) === $fieldName){
 				return true;
 			}
 		}
@@ -209,14 +210,15 @@
 	 */
 	private function isRelatedTermsField(string $fieldName): bool
 	{
-		if (!defined('JVB_TAXONOMY')) {
+
+		$posts = Registrar::getRegistered('term');
+		if (empty($posts)) {
 			return false;
 		}
 
-		// Check if field name matches any plural taxonomy
-		foreach (JVB_TAXONOMY as $taxonomy => $config) {
-			$plural = strtolower($config['plural'] ?? '');
-			if ($plural && $fieldName === $plural) {
+		foreach ($posts as $post) {
+			$registrar = Registrar::getInstance($post);
+			if ($registrar && strtolower($registrar->getPlural()) === $fieldName){
 				return true;
 			}
 		}
@@ -277,17 +279,20 @@
 	 */
 	private function getPostTypeFromPluralName(string $pluralName): ?string
 	{
-		if (!defined('JVB_CONTENT')) {
+
+		$posts = Registrar::getRegistered('post');
+		if (empty($posts)) {
 			return null;
 		}
 
-		foreach (JVB_CONTENT as $type => $config) {
-			$plural = strtolower($config['plural'] ?? '');
-			if ($plural === $pluralName) {
-				return $type;
+		foreach ($posts as $post) {
+			$registrar = Registrar::getInstance($post);
+			if ($registrar && strtolower($registrar->getPlural()) === $pluralName){
+				return $post;
 			}
 		}
 
+
 		return null;
 	}
 
@@ -296,17 +301,18 @@
 	 */
 	private function getTaxonomyFromPluralName(string $pluralName): ?string
 	{
-		if (!defined('JVB_TAXONOMY')) {
+
+		$posts = Registrar::getRegistered('term');
+		if (empty($posts)) {
 			return null;
 		}
 
-		foreach (JVB_TAXONOMY as $taxonomy => $config) {
-			$plural = strtolower($config['plural'] ?? '');
-			if ($plural === $pluralName) {
-				return $taxonomy;
+		foreach ($posts as $post) {
+			$registrar = Registrar::getInstance($post);
+			if ($registrar && strtolower($registrar->getPlural()) === $pluralName){
+				return $post;
 			}
 		}
-
 		return null;
 	}
 
@@ -650,14 +656,9 @@
 			return;
 		}
 
-		$typeKey = str_replace(BASE, '', $this->contentType);
-
-		if ($this->objectType === 'post' && defined('JVB_CONTENT')) {
-			$this->fieldDefinitions = JVB_CONTENT[$typeKey]['fields'] ?? [];
-		} elseif ($this->objectType === 'term' && defined('JVB_TAXONOMY')) {
-			$this->fieldDefinitions = JVB_TAXONOMY[$typeKey]['fields'] ?? [];
-		} elseif ($this->objectType === 'user' && defined('JVB_USER')) {
-			$this->fieldDefinitions = JVB_USER[$typeKey]['fields'] ?? [];
+		$registrar = Registrar::getInstance($this->contentType));
+		if ($registrar) {
+			$this->fieldDefinitions = $registrar->getFields();
 		}
 	}
 }

--
Gitblit v1.10.0