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/meta/Sanitizer.php | 40 +++++++++++++++++++++++++---------------
1 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/inc/meta/Sanitizer.php b/inc/meta/Sanitizer.php
index fa71881..03b6e39 100644
--- a/inc/meta/Sanitizer.php
+++ b/inc/meta/Sanitizer.php
@@ -14,13 +14,18 @@
public static function sanitize(mixed $value, array $field_config): mixed
{
$callback = static::getCallback($field_config);
+
+// $caller = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
+// error_log('Called from: '.print_r($caller, true));
+// $name = $field_config['name']??'';
+//
+// error_log('Sanitizing '.$name. ' with value: '.print_r($value, true));
+
if (is_array($callback)) {
return call_user_func([static::class, $callback[1]], $value, $field_config);
- }
- if (method_exists(static::class, $callback)) {
+ } elseif (method_exists(static::class, $callback)) {
return static::$callback($value, $field_config);
}
-
return call_user_func($callback, $value);
}
@@ -236,25 +241,30 @@
return implode(',', array_intersect($value, array_keys($field_config['options'])));
}
- protected static function sanitizeDate(string $value, array $field_config):string
- {
- $timestamp = strtotime($value);
- return $timestamp ? date('Y-m-d', $timestamp) : '';
- }
-
- protected static function sanitizeDateTime(string $value, array $field_config): string
+ protected static function sanitizeDate(?string $value, array $field_config): string
{
if (empty($value)) {
return '';
}
-
- $timestamp = strtotime($value);
- if (!$timestamp) {
+ try {
+ $date = new \DateTime($value, wp_timezone());
+ } catch (\Exception $e) {
return '';
}
+ return $date->format('Y-m-d');
+ }
- // Return in MySQL datetime format
- return date('Y-m-d H:i:s', $timestamp);
+ protected static function sanitizeDateTime(?string $value, array $field_config): string
+ {
+ if (empty($value)) {
+ return '';
+ }
+ try {
+ $date = new \DateTime($value, wp_timezone());
+ } catch (\Exception $e) {
+ return '';
+ }
+ return $date->format('Y-m-d H:i:s');
}
protected static function sanitizeTime(string $value, array $field_config):string
--
Gitblit v1.10.0