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/SchemaFieldHelpers.php | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/inc/managers/SEO/SchemaFieldHelpers.php b/inc/managers/SEO/SchemaFieldHelpers.php
index 6b9ba0d..e3d544c 100644
--- a/inc/managers/SEO/SchemaFieldHelpers.php
+++ b/inc/managers/SEO/SchemaFieldHelpers.php
@@ -1,7 +1,7 @@
<?php
namespace JVBase\managers\SEO;
-use JVBase\meta\MetaManager;
+use JVBase\meta\Meta;
if (!defined('ABSPATH')) {
exit;
@@ -21,10 +21,10 @@
*
* @param string $fieldName Field name
* @param mixed $value Raw value
- * @param MetaManager|null $meta Optional MetaManager for accessing related fields
+ * @param Meta|null $meta Optional Meta for accessing related fields
* @return mixed Enhanced value
*/
- public static function autoResolve(string $fieldName, mixed $value, ?MetaManager $meta = null): mixed
+ public static function autoResolve(string $fieldName, mixed $value, ?Meta $meta = null): mixed
{
// Skip empty values
if ($value === null || $value === '') {
@@ -72,7 +72,7 @@
// Rating -> AggregateRating (needs rating_count from meta)
'rating'
- => $meta ? self::buildAggregateRating($value, $meta->getValue('rating_count')) : $value,
+ => $meta ? self::buildAggregateRating($value, $meta->get('rating_count')) : $value,
// Geo coordinates
'geo'
@@ -197,7 +197,7 @@
*
* Returns array with 'address' and 'geo' keys
*
- * @param array $location Location data from MetaManager
+ * @param array $location Location data from Meta
* @return array Schema with address and geo fields
*/
public static function buildLocation(array $location): array
@@ -263,7 +263,7 @@
/**
* Build opening hours from repeater field
*
- * @param array $hours Hours data from MetaManager
+ * @param array $hours Hours data from Meta
* @return array Schema with openingHours field
*/
public static function buildOpeningHours(array $hours): array
@@ -293,7 +293,7 @@
/**
* Build sameAs array from links repeater
*
- * @param array $links Links data from MetaManager
+ * @param array $links Links data from Meta
* @return array Schema with sameAs field
*/
public static function buildSameAs(array $links): array
@@ -981,6 +981,26 @@
return $formatted;
}
+
+ /**
+ * Build a JSON-LD @id reference
+ * String → ['@id' => $value], array with @id → pass through
+ */
+ public static function reference(mixed $value): array|string
+ {
+ if (is_array($value) && isset($value['@id'])) {
+ return $value;
+ }
+
+ if (is_string($value) && !empty($value)) {
+ return ['@id' => $value];
+ }
+
+ return $value;
+ }
+
+
+
/**
* Build SiteNavigationElement array from navigation items
*/
--
Gitblit v1.10.0