From 1aa7c404dae63c9518468fe9b579fad819f8d871 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 13 Sep 2026 18:32:43 +0000
Subject: [PATCH] =Single Event page setup done through the new Event block. Currently working on the Simple Calendar block setup
---
inc/registrar/helpers/MakeCalendarType.php | 28 +++++++++++++++++++++++++---
1 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/inc/registrar/helpers/MakeCalendarType.php b/inc/registrar/helpers/MakeCalendarType.php
index 53909e9..8425ed1 100644
--- a/inc/registrar/helpers/MakeCalendarType.php
+++ b/inc/registrar/helpers/MakeCalendarType.php
@@ -1,6 +1,7 @@
<?php
namespace JVBase\registrar\helpers;
+use DateTime;
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
use WP_Post;
@@ -82,17 +83,20 @@
'hidden' => true,
],
'year' => [
- 'type' => 'number',
+ 'type' => 'text',
+ 'subtype' => 'number',
'label' => 'Year',
'hidden' => true,
],
'month' => [
- 'type' => 'number',
+ 'type' => 'text',
+ 'subtype' => 'number',
'label' => 'Month',
'hidden' => true,
],
'day' => [
- 'type' => 'number',
+ 'type' => 'text',
+ 'subtype' => 'number',
'label' => 'Day',
'hidden' => true,
],
@@ -129,6 +133,7 @@
'max_participants' => [
'type' => 'number',
'label' => 'Maximum Participants',
+ 'hint' => 'Leave 0 for no maximum'
],
'is_free' => [
'type' => 'true_false',
@@ -311,6 +316,23 @@
if ($post->post_type === $this->postType) {
$get = ['year', 'month','day'];
$values = Meta::forPost($post->ID)->getAll($get);
+
+ if (empty($values['year']) || empty($values['month']) || empty($values['day'])) {
+ $value = Meta::forPost($post->ID)->get('date_start');
+ if (!empty($value)) {
+ $date = new DateTime($value, wp_timezone());
+ $year = $date->format('Y');
+ $month = $date->format('m');
+ $day = $date->format('d');
+
+ $values = [
+ 'year' => $year,
+ 'month' => $month,
+ 'day' => $day
+ ];
+ Meta::forPost($post->ID)->setAll($values);
+ }
+ }
foreach ($values as $key => $value) {
if (!empty($value) && $value !== 0) {
$url = str_replace("%e$key%", $value, $url);
--
Gitblit v1.10.0