From 32ce5c542c90be348895328078e392dde2052957 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 04 Sep 2026 19:15:16 +0000
Subject: [PATCH] =Working at adding defined fields to a dedicated panel in the gutenberg editor. Registrar now has AddCustomFields.php, which currently only supports post fields. Added a @wordpress/plugins base _meta/fields in /build and /src that successfully creates a panel. Next steps: determine sections and fields, group fields by section (each section to a panel), and save output
---
inc/helpers/time.php | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/inc/helpers/time.php b/inc/helpers/time.php
index 4c3483c..d598e89 100644
--- a/inc/helpers/time.php
+++ b/inc/helpers/time.php
@@ -1,6 +1,6 @@
<?php
-use JVBase\base\Options;
+use JVBase\base\options;
use JVBase\managers\Cache;
use JVBase\meta\Meta;
@@ -26,6 +26,7 @@
* Format a date in relative time (e.g., "2 days ago")
* @param string $dateStr - Date string or DateTime object
* @return string - Formatted relative time
+ * @throws DateMalformedStringException
*/
function jvbFormatTimeAgo(string $dateStr):string
{
@@ -143,7 +144,10 @@
*/
function jvbRenderHours(int $ID, string $type = ''):string
{
- $cache = Cache::for('hours_display', WEEK_IN_SECONDS)->connect('taxonomy')->connect('post')->connect('user');
+ if (!$type) {
+ return '';
+ }
+ $cache = Cache::for('hours_display_'.$type, $type, WEEK_IN_SECONDS);
$cached = $cache->get($ID);
@@ -171,7 +175,7 @@
$out = '';
if (!empty($hours) && jvbHasOperatingHours($hours)) {
- $out = jvbGetFormattedHours($hours, true, true);
+ $out = jvbGetFormattedHours($hours);
} else {
$out = '<p class="no-hours">Hours not available</p>';
}
@@ -308,15 +312,17 @@
/**
* Check if business is currently open based on stored hours
*
- * @param array $hours_data Array of hours data from wp_option
+ * @param array|null $hours_data Array of hours data from wp_option
* @param string $timezone Timezone string (default: 'America/Edmonton')
* @return bool True if currently open, false if closed
+ * @throws DateInvalidTimeZoneException
+ * @throws DateMalformedStringException
*/
function jvbIsCurrentlyOpen(?array $hours_data = null, string $timezone = 'America/Edmonton'):bool
{
// Get hours data if not provided
if ($hours_data === null) {
- $hours_data = Options::get('openingHours');
+ $hours_data = options::get('openingHours');
}
// Return false if no hours data
@@ -365,10 +371,12 @@
* @param ?string $end_time End time in H:i format (e.g., '15:15')
* @param string $timezone Timezone string (default: 'America/Edmonton')
* @return bool True if current time is within range, false otherwise
+ * @throws DateInvalidTimeZoneException
+ * @throws DateMalformedStringException
*/
function jvbIsTimeBetween(?string $start_time = null, ?string $end_time = null, string $timezone = 'America/Edmonton'):bool {
if (!$start_time && !$end_time) {
- $hours = Options::get('today_hours');
+ $hours = options::get('today_hours');
$start_time = $hours['time_start'];
$end_time = $hours['time_end'];
}
@@ -398,6 +406,7 @@
* @param string $timezone Timezone string
* @return string Next opening time description or empty string if never opens
* @throws DateInvalidTimeZoneException
+ * @throws DateMalformedStringException
*/
function jvbGetNextOpeningTime(array $hours_data, string $timezone = 'America/Edmonton'):string {
if (!jvbHasOperatingHours($hours_data)) {
--
Gitblit v1.10.0