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/helpers/time.php |   30 +++++++++++++++++-------------
 1 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/inc/helpers/time.php b/inc/helpers/time.php
index 7670726..e83d48b 100644
--- a/inc/helpers/time.php
+++ b/inc/helpers/time.php
@@ -1,6 +1,7 @@
 <?php
 
 use JVBase\managers\Cache;
+use JVBase\meta\Meta;
 
 if (!defined('ABSPATH')) {
 	exit;
@@ -135,11 +136,11 @@
 
 /**
  * @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 = Cache::for('hours_display', WEEK_IN_SECONDS)->connect('taxonomy')->connect('post')->connect('user');
 
@@ -149,20 +150,22 @@
 		return $cached;
 	}
 
+	$meta = match($type){
+		'post'	=> Meta::forPost($ID),
+		'term'	=> Meta::forTerm($ID),
+		'user'	=> Meta::forUser($ID),
+		default	=> false
+	};
 	if (!$meta) {
-		if (term_exists($ID)) {
-			$type = 'term';
-		} elseif (get_post_status($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 = '';
 
@@ -392,6 +395,7 @@
  * @param array $hours_data Day-based hours data
  * @param string $timezone Timezone string
  * @return string|null Next opening time description or null if never opens
+ * @throws DateInvalidTimeZoneException
  */
 function jvbGetNextOpeningTime(array $hours_data, string $timezone = 'America/Edmonton'): ?string {
 	if (!jvbHasOperatingHours($hours_data)) {

--
Gitblit v1.10.0