From f4be611c51473359e6d41780f0313c446079e9d3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 09 Jun 2026 15:19:24 +0000
Subject: [PATCH] =Switched the /base/options.php to the same pattern as Site.php: a class based approached rather than a filter. Updated Meta.php to play along with the defined fields from there in Meta::forOptions. Had to change openingHoursSpecificationsTrait.php to not use the translater functions __('text','textdomain') for now, as we load before init.

---
 inc/meta/Meta.php |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/inc/meta/Meta.php b/inc/meta/Meta.php
index 744fae5..d870467 100644
--- a/inc/meta/Meta.php
+++ b/inc/meta/Meta.php
@@ -1,6 +1,7 @@
 <?php
 namespace JVBase\meta;
 
+use JVBase\base\Options;
 use JVBase\registrar\Registrar;
 use WP_Post;
 use WP_Term;
@@ -75,7 +76,7 @@
 	/**
 	 * Create Meta instance for options
 	 */
-	public static function forOptions(?string $baseKey = 'ajv'): self
+	public static function forOptions(?string $baseKey = BASE): self
 	{
 		if (array_key_exists($baseKey, self::$instances['options'])) {
 			return self::$instances['options'][$baseKey];
@@ -118,6 +119,10 @@
 
 		$registrar = !is_null($this->slug) ? Registrar::getInstance($this->slug) : false;
 		$fields = $registrar ? $registrar->getFields() : [];
+		if ($this->type == 'options') {
+			$options = Options::getInstance();
+			$fields = $options->getFields();
+		}
 		$meta = match($type) {
 			'post'	=> get_post_meta($id),
 			'term'	=> get_term_meta($id),
@@ -197,6 +202,11 @@
 		}
 		if (!array_key_exists($name, $this->fields)) {
 			error_log('[Meta]::get Attempted to get unregistered field: '.$name);
+			return '';
+		}
+		if (is_null($this->fields[$name])) {
+			error_log('[Meta]::get Field does not seem to be setup yet: '.$name);
+			return '';
 		}
 		return $this->fields[$name]->get()??'';
 	}

--
Gitblit v1.10.0