PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/DateTimeHelper.php +16 -15 1.7.1 → 2.5.0 View file →
@@ -67,9 +67,9 @@
67 67 {
68 68 $timeZone = self::getTimeZone();
69 69
70 70 if (isset($_COOKIE['fluent_booking_user_timezone'])) {
71 - $timeZone = $_COOKIE['fluent_booking_user_timezone'];
71 + $timeZone = sanitize_text_field(wp_unslash($_COOKIE['fluent_booking_user_timezone']));
72 72 }
73 73
74 74 return $timeZone;
75 75 }
@@ -90,9 +90,8 @@
90 90 }
91 91
92 92 public static function convertToUtc($dateTime, $timezone, $format = 'Y-m-d H:i:s')
93 93 {
94 -
95 94 $timezone = self::getValidatedTimeZone($timezone);
96 95
97 96 $dateTime = new \DateTime($dateTime, new \DateTimeZone($timezone));
98 97 $dateTime->setTimezone(new \DateTimeZone('UTC'));
@@ -175,19 +174,29 @@
175 174
176 175 public static function formatToLocale($dateTime, $for = 'date')
177 176 {
178 177 // $for can be date | date_time | time
179 - $dateFormat = get_option('date_format');
178 + $dateFormat = (string) get_option('date_format', '');
180 179
181 180 if ($for == 'date_time') {
182 - $dateFormat .= ' ' . get_option('time_format');
181 + $dateFormat .= ' ' . (string) get_option('time_format', '');
183 182 } elseif ($for == 'time') {
184 - $dateFormat = get_option('time_format');
183 + $dateFormat = (string) get_option('time_format', '');
185 184 }
186 185
187 186 return date_i18n($dateFormat, strtotime($dateTime)); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
188 187 }
189 188
189 + public static function getFormattedDate($date, $from = '', $to = 'Y-m-d')
190 + {
191 + if (!$from) {
192 + $from = (string) get_option('date_format', '');
193 + }
194 +
195 + $date = \DateTime::createFromFormat($from, $date);
196 + return $date ? $date->format($to) : '';
197 + }
198 +
190 199 public static function getAvailableDateFormats()
191 200 {
192 201 $dateFormats = apply_filters('fluent_booking/available_date_formats', [
193 202 'm/d/Y' => 'm/d/Y - (Ex: 05/20/2024)', // USA
@@ -287,22 +296,14 @@
287 296
288 297 for ($i = 0; $i < strlen($phpFormat); $i++) {
289 298 $char = $phpFormat[$i];
290 299
291 - // Special handling for G\hi pattern
292 - if ($char === 'G' && $i + 2 < strlen($phpFormat) &&
293 - $phpFormat[$i + 1] === '\\' && $phpFormat[$i + 2] === 'h') {
294 - $dayjsFormat .= 'H[h]';
295 - $i += 2;
296 - continue;
297 - }
298 -
299 300 // Check if the character is escaped
300 301 if ($char === "\\") {
301 - // Add the next character to the result as is, without mapping
302 + // Day.js escapes literal text with square brackets, not backslashes
302 303 $i++;
303 304 if ($i < strlen($phpFormat)) {
304 - $dayjsFormat .= "\\" . $phpFormat[$i];
305 + $dayjsFormat .= "[" . $phpFormat[$i] . "]";
305 306 }
306 307 continue;
307 308 }
308 309