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/Hooks/Handlers/FrontEndHandler.php +80 -215 2.2.0 → 2.5.0 View file →
@@ -8,8 +8,9 @@
8 8 use FluentBooking\App\Models\CalendarSlot;
9 9 use FluentBooking\App\Services\BookingFieldService;
10 10 use FluentBooking\App\Services\BookingService;
11 11 use FluentBooking\App\Services\DateTimeHelper;
12 +use FluentBooking\App\Services\PublicTransStrings;
12 13 use FluentBooking\App\Services\Helper;
13 14 use FluentBooking\App\Services\LandingPage\LandingPageHandler;
14 15 use FluentBooking\App\Services\LandingPage\LandingPageHelper;
15 16 use FluentBooking\App\Hooks\Handlers\TimeSlotServiceHandler;
@@ -14,11 +15,12 @@
14 15 use FluentBooking\App\Services\LandingPage\LandingPageHelper;
15 16 use FluentBooking\App\Hooks\Handlers\TimeSlotServiceHandler;
16 17 use FluentBooking\App\Services\CalendarEventService;
17 18 use FluentBooking\App\Services\LocationService;
18 -use FluentBooking\App\Services\PermissionManager;
19 +use FluentBooking\App\Services\RescheduleService;
19 20 use FluentBooking\App\Services\CurrenciesHelper;
20 21 use FluentBooking\Framework\Support\Arr;
22 +use FluentBooking\App\Vite;
21 23
22 24 class FrontEndHandler
23 25 {
24 26 public function register()
@@ -70,19 +72,17 @@
70 72 if (!$calendar) {
71 73 return __('Calendar not found', 'fluent-booking');
72 74 }
73 75
74 - $assetUrl = App::getInstance('url.assets');
75 -
76 76 $localizeData = $this->getCalendarEventVars($calendar, $calendarEvent);
77 77 $localizeData['disable_author'] = $atts['disable_author'] == 'yes';
78 78 $localizeData['theme'] = $atts['theme'];
79 79
80 80 if (BookingFieldService::hasPhoneNumberField($localizeData['form_fields'])) {
81 - wp_enqueue_script('fluent-booking-phone-field', $assetUrl . 'public/js/phone-field.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
81 + Vite::enqueueScript('fluent-booking-phone-field', 'phone_field', [], FLUENT_BOOKING_ASSETS_VERSION);
82 82 }
83 83
84 - wp_enqueue_script('fluent-booking-public', $assetUrl . 'public/js/app.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
84 + Vite::enqueueScript('fluent-booking-public', 'public_app', [], FLUENT_BOOKING_ASSETS_VERSION);
85 85
86 86 $this->loadGlobalVars();
87 87 wp_localize_script(
88 88 'fluent-booking-public',
@@ -130,9 +130,9 @@
130 130 $event = CalendarEventService::processEvent($event);
131 131 $calendarEvents[$event->calendar_id][] = $event;
132 132 }
133 133
134 - $calendars = Calendar::query()->whereIn('id', $calendarIds)->get();
134 + $calendars = Calendar::query()->with('metas')->whereIn('id', $calendarIds)->get();
135 135
136 136 foreach ($calendars as $calendar) {
137 137 $calendar->activeEvents = $calendarEvents[$calendar->id] ?? [];
138 138 $eventOrder = $calendar->getMeta('event_order');
@@ -157,9 +157,9 @@
157 157
158 158 public function renderTeamHosts($calendars, $headerConfig = [])
159 159 {
160 160 $wrapperId = 'fcal_team_' . Helper::getNextIndex();
161 - wp_enqueue_script('fluent-booking-team', App::getInstance('url.assets') . 'public/js/team_app.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
161 + Vite::enqueueScript('fluent-booking-team', 'team_app', [], FLUENT_BOOKING_ASSETS_VERSION);
162 162
163 163 $vars = [];
164 164 foreach ($calendars as $calendar) {
165 165 $hostHtml = (string)(string)\FluentBooking\App\App::getInstance('view')->make('landing.author_html', [
@@ -189,10 +189,9 @@
189 189 }
190 190
191 191 wp_localize_script('fluent-booking-team', $wrapperId, $vars);
192 192
193 - $assetUrl = App::getInstance('url.assets');
194 - wp_enqueue_script('fluent-booking-public', $assetUrl . 'public/js/app.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
193 + Vite::enqueueScript('fluent-booking-public', 'public_app', [], FLUENT_BOOKING_ASSETS_VERSION);
195 194 $this->loadGlobalVars();
196 195
197 196 return App::make('view')->make('public.team_page', [
198 197 'hosts' => $calendars,
@@ -273,9 +272,9 @@
273 272
274 273 public function renderCalendarBlock($calendar, $headerConfig = [])
275 274 {
276 275 $wrapperId = 'fcal_calendar_' . Helper::getNextIndex();
277 - wp_enqueue_script('fluent-booking-calendar', App::getInstance('url.assets') . 'public/js/calendar_app.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
276 + Vite::enqueueScript('fluent-booking-calendar', 'calendar_app', [], FLUENT_BOOKING_ASSETS_VERSION);
278 277
279 278 $calendarHtml = (string)(string)\FluentBooking\App\App::getInstance('view')->make('landing.author_html', [
280 279 'author' => $calendar->getAuthorProfile(),
281 280 'calendar' => $calendar,
@@ -302,10 +301,9 @@
302 301 }
303 302
304 303 wp_localize_script('fluent-booking-calendar', $wrapperId, $vars);
305 304
306 - $assetUrl = App::getInstance('url.assets');
307 - wp_enqueue_script('fluent-booking-public', $assetUrl . 'public/js/app.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
305 + Vite::enqueueScript('fluent-booking-public', 'public_app', [], FLUENT_BOOKING_ASSETS_VERSION);
308 306 $this->loadGlobalVars();
309 307
310 308 return App::make('view')->make('public.calendar_page', [
311 309 'calendar' => $calendar,
@@ -389,9 +387,9 @@
389 387 $periodOptions = Helper::getBookingPeriodOptions();
390 388
391 389 $pageOptions = apply_filters('fluent_booking/booking_per_page_options', [5, 10, 15, 20, 50, 100]);
392 390
393 - wp_enqueue_script('fluent-booking-list', App::getInstance('url.assets') . 'public/js/bookings.js', [], FLUENT_BOOKING_ASSETS_VERSION, true);
391 + Vite::enqueueScript('fluent-booking-list', 'bookings', [], FLUENT_BOOKING_ASSETS_VERSION);
394 392
395 393 return App::make('view')->make('public.bookings', [
396 394 'bookings' => $bookings,
397 395 'attributes' => $atts,
@@ -450,87 +448,28 @@
450 448 'message' => __('Invalid rescheduling request', 'fluent-booking')
451 449 ], 422);
452 450 }
453 451
454 - // The booking must be rescheduled against its own event. Reject mixed-object
455 - // requests where the posted event_id differs from the booking's event so the
456 - // availability validation cannot be performed under a different event than the
457 - // one actually being modified.
458 - if ((int) $existingBooking->event_id !== (int) $calendarEvent->id) {
459 - wp_send_json([
460 - 'message' => __('Invalid rescheduling request', 'fluent-booking')
461 - ], 422);
462 - }
452 + $result = RescheduleService::reschedule(
453 + $existingBooking,
454 + $calendarEvent,
455 + $bookingData['start_time'],
456 + $bookingData['person_time_zone'],
457 + [
458 + 'reason' => Arr::get($postedData, 'rescheduling_reason', ''),
459 + 'host_user_id' => Arr::get($bookingData, 'host_user_id'),
460 + 'source' => __('Web UI', 'fluent-booking')
461 + ]
462 + );
463 463
464 - $rescheduleBy = 'guest';
465 - $hostIds = $existingBooking->getHostIds();
466 - if (in_array(get_current_user_id(), $hostIds) || PermissionManager::userCan(['manage_all_data', 'manage_all_bookings'])) {
467 - $rescheduleBy = 'host';
468 - }
469 -
470 - $existingBooking->updateMeta('rescheduled_by_type', $rescheduleBy);
471 -
472 - if ($rescheduleBy == 'guest' && !$existingBooking->canReschedule()) {
464 + if (is_wp_error($result)) {
473 465 wp_send_json([
474 - 'message' => $existingBooking->getRescheduleMessage()
466 + 'message' => $result->get_error_message()
475 467 ], 422);
476 468 }
477 469
478 - if ($bookingData['start_time'] == $existingBooking->start_time) {
479 - wp_send_json([
480 - 'message' => __('Sorry! you can not reschedule to the same time.', 'fluent-booking')
481 - ], 422);
482 - }
470 + $existingBooking = $result;
483 471
484 - $endDateTime = gmdate('Y-m-d H:i:s', strtotime($bookingData['start_time']) + ($existingBooking->slot_minutes * 60)); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
485 -
486 - $previousBooking = clone $existingBooking;
487 -
488 - if ($existingBooking->isMultiGuestBooking()) {
489 - // Need to handle group booking type here
490 - // check for existing group
491 - $parent = Booking::where('status', 'scheduled')
492 - ->where('event_id', $existingBooking->event_id)
493 - ->where('start_time', $bookingData['start_time'])
494 - ->orderBy('id', 'ASC')
495 - ->first();
496 -
497 - if ($parent) {
498 - $existingBooking->group_id = $parent->group_id;
499 - } else {
500 - $existingBooking->group_id = Helper::getNextBookingGroup();
501 - }
502 - }
503 -
504 - if ($existingBooking->isRoundRobinBooking()) {
505 - $hostId = $bookingData['host_user_id'];
506 - $existingBooking->host_user_id = $hostId;
507 - $existingBooking->hosts()->sync([$hostId]);
508 - }
509 -
510 - $existingBooking->start_time = $bookingData['start_time'];
511 - $existingBooking->person_time_zone = $bookingData['person_time_zone'];
512 - $existingBooking->end_time = $endDateTime;
513 - $existingBooking->save();
514 -
515 - $existingBooking->updateMeta('previous_meeting_time', $previousBooking->start_time);
516 -
517 - $reschedulingMessage = sanitize_textarea_field(Arr::get($postedData, 'rescheduling_reason'));
518 - if ($reschedulingMessage) {
519 - $existingBooking->updateMeta('reschedule_reason', $reschedulingMessage);
520 - }
521 -
522 - do_action('fluent_booking/log_booking_activity', [
523 - 'booking_id' => $existingBooking->id,
524 - 'type' => 'info',
525 - 'status' => 'closed',
526 - 'title' => __('Meeting Rescheduled', 'fluent-booking'),
527 - /* translators: %1$s is the user who rescheduled the meeting, %2$s is the previous date and time in UTC. */
528 - 'description' => sprintf(__('Meeting has been rescheduled by %1$s from Web UI. Previous date time: %2$s (UTC)', 'fluent-booking'), $rescheduleBy, $previousBooking->start_time)
529 - ]);
530 -
531 - do_action('fluent_booking/after_booking_rescheduled', $existingBooking, $previousBooking, $calendarEvent);
532 -
533 472 add_filter('fluent_booking/schedule_receipt_data', function ($data) {
534 473 $data['title'] = __('Your meeting has been rescheduled', 'fluent-booking');
535 474 return $data;
536 475 });
@@ -616,84 +555,12 @@
616 555 'ajaxurl' => admin_url('admin-ajax.php'),
617 556 'timezones' => DateTimeHelper::getFlatGroupedTimeZones(),
618 557 'current_person' => $currentPerson,
619 558 'start_day' => $startDay,
620 - 'i18' => [
621 - 'Timezone' => __('Timezone', 'fluent-booking'),
622 - 'Day' => __('Day', 'fluent-booking'),
623 - 'Days' => __('Days', 'fluent-booking'),
624 - 'Hour' => __('Hour', 'fluent-booking'),
625 - 'Hours' => __('Hours', 'fluent-booking'),
626 - 'Minute' => __('Minute', 'fluent-booking'),
627 - 'Minutes' => __('Minutes', 'fluent-booking'),
628 - 'week' => __('week', 'fluent-booking'),
629 - 'month' => __('month', 'fluent-booking'),
630 - 'year' => __('year', 'fluent-booking'),
631 - 'weeks' => __('weeks', 'fluent-booking'),
632 - 'months' => __('months', 'fluent-booking'),
633 - 'years' => __('years', 'fluent-booking'),
634 - 'Every' => __('Every', 'fluent-booking'),
635 - 'for' => __('for', 'fluent-booking'),
636 - 'Number of Occurrences' => __('Number of Occurrences', 'fluent-booking'),
637 - 'occurrence' => __('occurrence', 'fluent-booking'),
638 - 'occurrences' => __('occurrences', 'fluent-booking'),
639 - 'You can only book up to' => __('You can only book up to', 'fluent-booking'),
640 - 'at a time' => __('at a time', 'fluent-booking'),
641 - 'Enter Details' => __('Enter Details', 'fluent-booking'),
642 - 'Summary' => __('Summary', 'fluent-booking'),
643 - 'Payment Details' => __('Payment Details', 'fluent-booking'),
644 - 'Item' => __('Item', 'fluent-booking'),
645 - 'Price' => __('Price', 'fluent-booking'),
646 - 'Quantity' => __('Quantity', 'fluent-booking'),
647 - 'Subtotal:' => __('Subtotal:', 'fluent-booking'),
648 - 'Total:' => __('Total:', 'fluent-booking'),
649 - 'Total Payment' => __('Total Payment', 'fluent-booking'),
650 - 'Payment Method' => __('Payment Method', 'fluent-booking'),
651 - 'Pay Now' => __('Pay Now', 'fluent-booking'),
652 - 'processing' => __('Processing', 'fluent-booking'),
653 - 'date_time_config' => DateTimeHelper::getI18nDateTimeConfig(),
654 - 'Country' => __('Country', 'fluent-booking'),
655 - '12h' => _x('12h', 'date time format switch', 'fluent-booking'),
656 - '24h' => _x('24h', 'date time format switch', 'fluent-booking'),
657 - 'spots left' => _x('spots left', 'for how many spots left for available booking', 'fluent-booking'),
658 - 'spots remaining' => _x('spots remaining', 'for how many spots remaining for available booking', 'fluent-booking'),
659 - 'Next' => _x('Next', 'Booking form spot selection', 'fluent-booking'),
660 - 'Select on the Next Step' => __('Select on the Next Step', 'fluent-booking'),
661 - 'location options' => __('location options', 'fluent-booking'),
662 - 'Your address' => __('Your address', 'fluent-booking'),
663 - 'Organizer Phone Number' => __('Organizer Phone Number', 'fluent-booking'),
664 - 'In Person (Attendee Address)' => __('In Person (Attendee Address)', 'fluent-booking'),
665 - 'In Person (Organizer Address)' => __('In Person (Organizer Address)', 'fluent-booking'),
666 - 'Attendee Phone Number' => __('Attendee Phone Number', 'fluent-booking'),
667 - 'Google Meet' => __('Google Meet', 'fluent-booking'),
668 - 'Zoom Meeting' => __('Zoom Meeting', 'fluent-booking'),
669 - 'Online Meeting' => __('Online Meeting', 'fluent-booking'),
670 - 'Phone Call' => __('Phone Call', 'fluent-booking'),
671 - 'Processing...' => __('Processing...', 'fluent-booking'),
672 - 'Loading Payment Processor...' => __('Loading Payment Processor...', 'fluent-booking'),
673 - 'PM' => __('PM', 'fluent-booking'),
674 - 'AM' => __('AM', 'fluent-booking'),
675 - 'Name' => __('Name', 'fluent-booking'),
676 - 'Email' => __('Email', 'fluent-booking'),
677 - 'Date' => __('Date', 'fluent-booking'),
678 - 'Time' => __('Time', 'fluent-booking'),
679 - 'per occurrence' => __('per occurrence', 'fluent-booking'),
680 - 'per guest' => __('per guest', 'fluent-booking'),
681 - 'Add guest' => __('Add guest', 'fluent-booking'),
682 - 'Add guests' => __('Add guests', 'fluent-booking'),
683 - 'Add another' => __('Add another', 'fluent-booking'),
684 - 'Choose File' => __('Choose File', 'fluent-booking'),
685 - 'This field is required.' => __('This field is required.', 'fluent-booking'),
686 - 'No availability in' => __('No availability in', 'fluent-booking'),
687 - 'View next month' => __('View next month', 'fluent-booking'),
688 - 'View previous month' => __('View previous month', 'fluent-booking'),
689 - 'No_payment_method_description' => __('No activated payment method found. If you are an admin please check the event payment settings', 'fluent-booking'),
690 - 'Please fill up the required data' => __('Please fill up the required data', 'fluent-booking'),
691 - 'Please select a valid payment method' => __('Please select a valid payment method', 'fluent-booking'),
692 - 'Please Select' => __('Please Select', 'fluent-booking'),
693 - 'Something is wrong!' => __('Something is wrong!', 'fluent-booking'),
694 - 'Requires Confirmation' => __('Requires Confirmation', 'fluent-booking'),
695 - ],
559 + // Generated from the i18() calls in resources/public; see scripts/i18n.js.
560 + 'i18' => array_merge(PublicTransStrings::getStrings(), [
561 + 'date_time_config' => DateTimeHelper::getI18nDateTimeConfig(),
562 + ]),
696 563 'theme' => Arr::get(get_option('_fluent_booking_settings'), 'theme', 'system-default'),
697 564 'currency_settings' => CurrenciesHelper::getGlobalCurrencySettings()
698 565 ];
699 566
@@ -750,9 +617,9 @@
750 617 'start_date.required' => __('Please select a date and time', 'fluent-booking')
751 618 ];
752 619
753 620 if ($calendarEvent->isPhoneRequired()) {
754 - $rules['phone_number'] = 'required';
621 + $rules['phone_number'] = ['required', $this->validPhoneNumberRule()];
755 622 $messages['phone_number.required'] = __('Please provide your phone number', 'fluent-booking');
756 623 } else if ($calendarEvent->isAddressRequired()) {
757 624 $rules['address'] = 'required';
758 625 $messages['address.required'] = __('Please provide your Address', 'fluent-booking');
@@ -763,12 +630,13 @@
763 630 $selectedLocation = LocationService::getLocationDetails($calendarEvent, Arr::get($postedData, 'location_config', []), $postedData);
764 631 $selectedLocationDriver = Arr::get($selectedLocation, 'type');
765 632 // is user input required
766 633 if (in_array($selectedLocationDriver, ['in_person_guest', 'phone_guest'])) {
767 - $rules['location_config.user_location_input'] = 'required';
768 634 if ($selectedLocationDriver == 'in_person_guest') {
635 + $rules['location_config.user_location_input'] = 'required';
769 636 $messages['location_config.user_location_input.required'] = __('Please provide your address', 'fluent-booking');
770 637 } else {
638 + $rules['location_config.user_location_input'] = ['required', $this->validPhoneNumberRule()];
771 639 $messages['location_config.user_location_input.required'] = __('Please provide your phone number', 'fluent-booking');
772 640 }
773 641 }
774 642 }
@@ -905,10 +773,12 @@
905 773 if (is_wp_error($timeSlotService)) {
906 774 return TimeSlotServiceHandler::sendError($timeSlotService, $calendarEvent, $timezone);
907 775 }
908 776
909 - $availableSpot = $timeSlotService->isSpotAvailable($bookingData['start_time'], $bookingData['end_time'], $duration);
777 + $isSlotLocked = Helper::lockRoundRobinSlot($calendarEvent, $bookingData['start_time'], $bookingData['end_time']);
910 778
779 + $availableSpot = $isSlotLocked ? $timeSlotService->isSpotAvailable($bookingData['start_time'], $bookingData['end_time'], $duration) : false;
780 +
911 781 if (!$availableSpot) {
912 782 wp_send_json([
913 783 'message' => __('This selected time slot is not available. Maybe someone booked the spot just a few seconds ago.', 'fluent-booking')
914 784 ], 422);
@@ -955,8 +825,20 @@
955 825 'booking_hash' => $booking->hash
956 826 ], $booking), 200);
957 827 }
958 828
829 + /**
830 + * @return \Closure
831 + */
832 + private function validPhoneNumberRule()
833 + {
834 + return function ($attribute, $value) {
835 + if (!empty($value) && !Helper::isValidPhoneNumber($value)) {
836 + return __('Please provide a valid phone number', 'fluent-booking');
837 + }
838 + };
839 + }
840 +
959 841 public function ajaxGetAvailableDates()
960 842 {
961 843 if (!Helper::checkRateLimit('available_dates', 30)) {
962 844 wp_send_json_error(['message' => __('Too many requests. Please try again in a minute.', 'fluent-booking')], 429);
@@ -965,20 +847,30 @@
965 847 $startBenchmark = microtime(true);
966 848
967 849 $request = $_REQUEST; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
968 850
969 - $eventId = (int)$request['event_id'];
851 + $eventId = (int)Arr::get($request, 'event_id');
970 852
971 - $rescheduling = Arr::get($request, 'rescheduling', 'no');
853 + $reschedulingHash = sanitize_text_field(Arr::get($request, 'rescheduling_hash', '')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
972 854
973 - $calendarEvent = CalendarSlot::findOrfail($eventId);
855 + $calendarEvent = $eventId ? CalendarSlot::find($eventId) : null;
974 856
975 - if (!$calendarEvent || ($calendarEvent->status != 'active' && $rescheduling == 'no')) {
857 + if (!$calendarEvent) {
976 858 wp_send_json([
977 859 'message' => __('Sorry, the host is not accepting any new bookings at the moment.', 'fluent-booking')
978 860 ], 422);
979 861 }
980 862
863 + if ($calendarEvent->status != 'active') {
864 + $existingBooking = $reschedulingHash ? Booking::where('hash', $reschedulingHash)->first() : null;
865 +
866 + if (!$existingBooking || (int)$existingBooking->event_id !== (int)$calendarEvent->id) {
867 + wp_send_json([
868 + 'message' => __('Sorry, the host is not accepting any new bookings at the moment.', 'fluent-booking')
869 + ], 422);
870 + }
871 + }
872 +
981 873 $calendar = $calendarEvent->calendar;
982 874 $startDate = sanitize_text_field(Arr::get($request, 'start_date')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
983 875
984 876 if (!$startDate) {
@@ -1021,8 +913,20 @@
1021 913 }
1022 914
1023 915 public function getCalendarEventVars(Calendar $calendar, CalendarSlot $calendarEvent)
1024 916 {
917 + static $globalConfig = null;
918 + if ($globalConfig === null) {
919 + $globalConfig = [
920 + 'time_format' => Arr::get(get_option('_fluent_booking_settings'), 'time_format', '12'),
921 + 'date_formatter' => DateTimeHelper::getDateFormatter(true),
922 + 'isRtl' => Helper::fluentbooking_is_rtl(),
923 + 'has_pro' => defined('FLUENT_BOOKING_PRO_DIR_FILE'),
924 + 'duration_lookup' => Helper::getDurationLookup(),
925 + 'multi_duration_lookup' => Helper::getDurationLookup(true),
926 + ];
927 + }
928 +
1025 929 $calendarEvent->description = wpautop($calendarEvent->description);
1026 930 $calendarEvent->location_icon_html = $calendarEvent->defaultLocationHtml();
1027 931 $formFields = BookingFieldService::getBookingFields($calendarEvent);
1028 932
@@ -1033,9 +937,9 @@
1033 937 'min_bookable_date' => $calendarEvent->getMinBookableDateTime(),
1034 938 'is_display_spots' => $calendarEvent->isDisplaySpots(),
1035 939 'duration' => $calendarEvent->getDefaultDuration(),
1036 940 'title' => $calendarEvent->title,
1037 - 'location_settings' => $this->sanitizePublicLocationSettings($calendarEvent->location_settings),
941 + 'location_settings' => LocationService::sanitizePublicLocationSettings($calendarEvent->location_settings),
1038 942 'location_icon_html' => $calendarEvent->location_icon_html,
1039 943 'description' => $calendarEvent->description,
1040 944 'pre_selects' => null,
1041 945 'settings' => $this->sanitizePublicEventSettings($calendarEvent->settings),
@@ -1040,9 +944,9 @@
1040 944 'pre_selects' => null,
1041 945 'settings' => $this->sanitizePublicEventSettings($calendarEvent->settings),
1042 946 'type' => $calendarEvent->type,
1043 947 'event_type' => $calendarEvent->event_type,
1044 - 'time_format' => Arr::get(get_option('_fluent_booking_settings'), 'time_format', '12'),
948 + 'time_format' => $globalConfig['time_format'],
1045 949 ];
1046 950
1047 951 $author = $calendar->getAuthorProfile(true);
1048 952 $author['name'] = $calendar->title;
@@ -1055,13 +959,13 @@
1055 959 'Schedule_Meeting' => __('Schedule Meeting', 'fluent-booking'),
1056 960 'Continue_to_Payments' => __('Continue to Payments', 'fluent-booking'),
1057 961 'Confirm_Payment' => __('Confirm Payment', 'fluent-booking'),
1058 962 ],
1059 - 'date_formatter' => DateTimeHelper::getDateFormatter(true),
1060 - 'isRtl' => Helper::fluentbooking_is_rtl(),
1061 - 'has_pro' => defined('FLUENT_BOOKING_PRO_DIR_FILE'),
1062 - 'duration_lookup' => Helper::getDurationLookup(),
1063 - 'multi_duration_lookup' => Helper::getDurationLookup(true)
963 + 'date_formatter' => $globalConfig['date_formatter'],
964 + 'isRtl' => $globalConfig['isRtl'],
965 + 'has_pro' => $globalConfig['has_pro'],
966 + 'duration_lookup' => $globalConfig['duration_lookup'],
967 + 'multi_duration_lookup' => $globalConfig['multi_duration_lookup']
1064 968 ];
1065 969
1066 970 $eventVars['form_fields'] = array_values($eventVars['form_fields']);
1067 971
@@ -1069,47 +973,8 @@
1069 973 $eventVars['team_member_profiles'] = $calendarEvent->getAuthorProfiles(true);
1070 974 }
1071 975
1072 976 return apply_filters('fluent_booking/public_event_vars', $eventVars, $calendarEvent);
1073 - }
1074 -
1075 - private function sanitizePublicLocationSettings($locationSettings)
1076 - {
1077 - if (!is_array($locationSettings)) {
1078 - return [];
1079 - }
1080 -
1081 - $safe = [];
1082 - foreach ($locationSettings as $location) {
1083 - if (!is_array($location)) {
1084 - continue;
1085 - }
1086 -
1087 - $type = Arr::get($location, 'type');
1088 - $displayOnBooking = Arr::get($location, 'display_on_booking') === 'yes';
1089 -
1090 - $sanitized = [
1091 - 'type' => $type,
1092 - 'title' => Arr::get($location, 'title'),
1093 - 'display_on_booking' => Arr::get($location, 'display_on_booking', 'no'),
1094 - ];
1095 -
1096 - // Only expose host-private fields when the host explicitly opted
1097 - // in to display them before booking.
1098 - if ($displayOnBooking) {
1099 - if ($type === 'online_meeting') {
1100 - $sanitized['meeting_link'] = Arr::get($location, 'meeting_link');
1101 - } elseif ($type === 'phone_organizer') {
1102 - $sanitized['host_phone_number'] = Arr::get($location, 'host_phone_number');
1103 - } elseif (in_array($type, ['in_person_organizer', 'custom'], true)) {
1104 - $sanitized['description'] = Arr::get($location, 'description');
1105 - }
1106 - }
1107 -
1108 - $safe[] = $sanitized;
1109 - }
1110 -
1111 - return $safe;
1112 977 }
1113 978
1114 979 private function sanitizePublicEventSettings($settings)
1115 980 {