From 2127b1bdd73ecd2423e443992da4b442f5a3c1a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 04 Feb 2026 21:19:25 +0000
Subject: [PATCH] =Major overhaul of MetaManager.php -> Meta.php and RestRouteManager.php -> Rest.php. Seems to work for JakeVan

---
 inc/helpers/time.php |   39 +++++++++++++++++++++------------------
 1 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/inc/helpers/time.php b/inc/helpers/time.php
index 6f94c49..241dc1c 100644
--- a/inc/helpers/time.php
+++ b/inc/helpers/time.php
@@ -1,6 +1,7 @@
 <?php
 
-use JVBase\managers\CacheManager;
+use JVBase\managers\Cache;
+use JVBase\meta\Meta;
 
 if (!defined('ABSPATH')) {
 	exit;
@@ -135,34 +136,36 @@
 
 /**
  * @param int $ID
- * @param JVBase\Meta\MetaManager $meta
+ * @param string $type
  *
  * @return string
  */
-function jvbRenderHours(int $ID, JVBase\Meta\MetaManager $meta):string
+function jvbRenderHours(int $ID, string $type = ''):string
 {
-	$cache = CacheManager::for('hours-'.$ID, WEEK_IN_SECONDS)->connectTo('taxonomy');
-	$key = 'hours_display';
-	$cached = $cache->get($key);
+	$cache = Cache::for('hours_display', WEEK_IN_SECONDS)->connect('taxonomy')->connect('post')->connect('user');
+
+	$cached = $cache->get($ID);
 
 	if ($cached !== false) {
 		return $cached;
 	}
 
+	$meta = match($type){
+		'post'	=> Meta::forPost($ID),
+		'term'	=> Meta::forTerm($ID),
+		'user'	=> Meta::forUser($ID),
+		default	=> false
+	};
 	if (!$meta) {
-		if (term_exists((int)$ID)) {
-			$type = 'term';
-		} elseif (get_post_status((int)$ID)) {
-			$type = 'post';
-		} else {
-			$type = 'user';
-		}
-		$meta = new JVBase\meta\MetaManager($ID, $type);
+		$meta = jvbGetMeta($ID);
+	}
+	if (!$meta) {
+		return '';
 	}
 
-	$hours = $meta->getValue('hours');
-	$byAppt = $meta->getValue('by_appointment');
-	$walkins = $meta->getValue('walkins');
+	$hours = $meta->get('hours');
+	$byAppt = $meta->get('by_appointment');
+	$walkins = $meta->get('walkins');
 
 	$out = '';
 
@@ -185,7 +188,7 @@
 		$out .= '<p class="hours-notes"><small>' . implode(' • ', $notes) . '</small></p>';
 	}
 
-	$cache->set($key, $out);
+	$cache->set($ID, $out);
 	return $out;
 }
 

--
Gitblit v1.10.0