From 3baf3d2545ba6ece6b74a64c0def59bd0774cf54 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 10 Jun 2026 16:34:12 +0000
Subject: [PATCH] =Laid the groundwork for an improved DashboardManager.php setup. Have to put it aside so I can get the dang Northeh done though.
---
inc/managers/SEO/render/Traits/_Properties/openingHoursSpecificationTrait.php | 66 +++++++++++++++++++++++++++++----
1 files changed, 58 insertions(+), 8 deletions(-)
diff --git a/inc/managers/SEO/render/Traits/_Properties/openingHoursSpecificationTrait.php b/inc/managers/SEO/render/Traits/_Properties/openingHoursSpecificationTrait.php
index f9aba4a..b21a54b 100644
--- a/inc/managers/SEO/render/Traits/_Properties/openingHoursSpecificationTrait.php
+++ b/inc/managers/SEO/render/Traits/_Properties/openingHoursSpecificationTrait.php
@@ -4,6 +4,8 @@
use JVBase\base\SchemaHelper;
use JVBase\managers\SEO\render\Thing\Intangible\StructuredValue\OpeningHoursSpecification;
use JVBase\managers\SEO\render\Traits\_Helpers\arrayHelper;
+use JVBase\meta\Meta;
+use JVBase\registrar\Fields;
if (!defined('ABSPATH')) {
exit;
@@ -41,15 +43,15 @@
$this->openingHoursSpecification = $openingHoursSpecification;
}
- public function getOpeningHoursSpecificationFieldConfig():array
+ public function setOpeningHoursSpecificationField(Fields $fields):void
{
- return [
+ $fields->addField('openingHours', [
'type' => 'repeater',
'label' => 'Opening Hours',
'fields' => [
'dayOfWeek' => [
- 'type' => 'radio',
- 'label' => 'Day(s) of Week',
+ 'type' => 'set',
+ 'label' => 'Day(s) of Week',
'options' => [
'Mo' => 'Monday',
'Tu' => 'Tuesday',
@@ -58,17 +60,65 @@
'Fr' => 'Friday',
'Sa' => 'Saturday',
'Su' => 'Sunday'
- ]
+ ],
+ 'required' => true
],
'opens' => [
'type' => 'time',
- 'label' => 'Opens At',
+ 'label' => 'Opens at',
+ 'required' => true
],
'closes' => [
'type' => 'time',
- 'label' => 'Closes At',
+ 'label' => 'Closes at',
+ 'required' => true
]
]
- ];
+ ]);
+ $fields->addField('by_appointment', [
+ 'type' => 'true_false',
+ 'label' => 'By Appointment Only',
+ ]);
+ $fields->addField('allow_walkins', [
+ 'type' => 'true_false',
+ 'label' => 'Walk Ins Welcome'
+ ]);
+ }
+ public function formatOpeningHoursSpecificationField(Meta $meta):void
+ {
+ $openingHours = $meta->get('openingHours');
+
+ if (!empty($openingHours)) {
+ $used = [
+ 'Mo' => false,
+ 'Tu' => false,
+ 'We' => false,
+ 'Th' => false,
+ 'Fr' => false,
+ 'Sa' => false,
+ 'Su' => false,
+ ];
+ $hours = [];
+ foreach ($openingHours as $row) {
+ $days = array_filter(explode(',', $row['dayOfWeek']),
+ function ($d) use ($used) {
+ if ($used[$d] === false) {
+ $used[$d] = true;
+ return true;
+ }
+ return false;
+ });
+ if (empty($days)) {
+ continue;
+ }
+ $opens = new OpeningHoursSpecification();
+ $opens->setDayOfWeek($days);
+ $opens->setOpens($row['opens']);
+ $opens->setCloses($row['closes']);
+ }
+ if (!empty($hours)){
+ $this->setOpeningHoursSpecification($hours);
+ }
+ }
}
}
--
Gitblit v1.10.0