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 -205 2.1.2 → 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,77 +448,28 @@
450 448 'message' => __('Invalid rescheduling request', 'fluent-booking')
451 449 ], 422);
452 450 }
453 451
454 - $rescheduleBy = 'guest';
455 - $hostIds = $existingBooking->getHostIds();
456 - if (in_array(get_current_user_id(), $hostIds) || PermissionManager::userCan(['manage_all_data', 'manage_all_bookings'])) {
457 - $rescheduleBy = 'host';
458 - }
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 + );
459 463
460 - $existingBooking->updateMeta('rescheduled_by_type', $rescheduleBy);
461 -
462 - if ($rescheduleBy == 'guest' && !$existingBooking->canReschedule()) {
464 + if (is_wp_error($result)) {
463 465 wp_send_json([
464 - 'message' => $existingBooking->getRescheduleMessage()
466 + 'message' => $result->get_error_message()
465 467 ], 422);
466 468 }
467 469
468 - if ($bookingData['start_time'] == $existingBooking->start_time) {
469 - wp_send_json([
470 - 'message' => __('Sorry! you can not reschedule to the same time.', 'fluent-booking')
471 - ], 422);
472 - }
470 + $existingBooking = $result;
473 471
474 - $endDateTime = gmdate('Y-m-d H:i:s', strtotime($bookingData['start_time']) + ($existingBooking->slot_minutes * 60)); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
475 -
476 - $previousBooking = clone $existingBooking;
477 -
478 - if ($existingBooking->isMultiGuestBooking()) {
479 - // Need to handle group booking type here
480 - // check for existing group
481 - $parent = Booking::where('status', 'scheduled')
482 - ->where('event_id', $existingBooking->event_id)
483 - ->where('start_time', $bookingData['start_time'])
484 - ->orderBy('id', 'ASC')
485 - ->first();
486 -
487 - if ($parent) {
488 - $existingBooking->group_id = $parent->group_id;
489 - } else {
490 - $existingBooking->group_id = Helper::getNextBookingGroup();
491 - }
492 - }
493 -
494 - if ($existingBooking->isRoundRobinBooking()) {
495 - $hostId = $bookingData['host_user_id'];
496 - $existingBooking->host_user_id = $hostId;
497 - $existingBooking->hosts()->sync([$hostId]);
498 - }
499 -
500 - $existingBooking->start_time = $bookingData['start_time'];
501 - $existingBooking->person_time_zone = $bookingData['person_time_zone'];
502 - $existingBooking->end_time = $endDateTime;
503 - $existingBooking->save();
504 -
505 - $existingBooking->updateMeta('previous_meeting_time', $previousBooking->start_time);
506 -
507 - $reschedulingMessage = sanitize_textarea_field(Arr::get($postedData, 'rescheduling_reason'));
508 - if ($reschedulingMessage) {
509 - $existingBooking->updateMeta('reschedule_reason', $reschedulingMessage);
510 - }
511 -
512 - do_action('fluent_booking/log_booking_activity', [
513 - 'booking_id' => $existingBooking->id,
514 - 'type' => 'info',
515 - 'status' => 'closed',
516 - 'title' => __('Meeting Rescheduled', 'fluent-booking'),
517 - /* translators: %1$s is the user who rescheduled the meeting, %2$s is the previous date and time in UTC. */
518 - 'description' => sprintf(__('Meeting has been rescheduled by %1$s from Web UI. Previous date time: %2$s (UTC)', 'fluent-booking'), $rescheduleBy, $previousBooking->start_time)
519 - ]);
520 -
521 - do_action('fluent_booking/after_booking_rescheduled', $existingBooking, $previousBooking, $calendarEvent);
522 -
523 472 add_filter('fluent_booking/schedule_receipt_data', function ($data) {
524 473 $data['title'] = __('Your meeting has been rescheduled', 'fluent-booking');
525 474 return $data;
526 475 });
@@ -606,84 +555,12 @@
606 555 'ajaxurl' => admin_url('admin-ajax.php'),
607 556 'timezones' => DateTimeHelper::getFlatGroupedTimeZones(),
608 557 'current_person' => $currentPerson,
609 558 'start_day' => $startDay,
610 - 'i18' => [
611 - 'Timezone' => __('Timezone', 'fluent-booking'),
612 - 'Day' => __('Day', 'fluent-booking'),
613 - 'Days' => __('Days', 'fluent-booking'),
614 - 'Hour' => __('Hour', 'fluent-booking'),
615 - 'Hours' => __('Hours', 'fluent-booking'),
616 - 'Minute' => __('Minute', 'fluent-booking'),
617 - 'Minutes' => __('Minutes', 'fluent-booking'),
618 - 'week' => __('week', 'fluent-booking'),
619 - 'month' => __('month', 'fluent-booking'),
620 - 'year' => __('year', 'fluent-booking'),
621 - 'weeks' => __('weeks', 'fluent-booking'),
622 - 'months' => __('months', 'fluent-booking'),
623 - 'years' => __('years', 'fluent-booking'),
624 - 'Every' => __('Every', 'fluent-booking'),
625 - 'for' => __('for', 'fluent-booking'),
626 - 'Number of Occurrences' => __('Number of Occurrences', 'fluent-booking'),
627 - 'occurrence' => __('occurrence', 'fluent-booking'),
628 - 'occurrences' => __('occurrences', 'fluent-booking'),
629 - 'You can only book up to' => __('You can only book up to', 'fluent-booking'),
630 - 'at a time' => __('at a time', 'fluent-booking'),
631 - 'Enter Details' => __('Enter Details', 'fluent-booking'),
632 - 'Summary' => __('Summary', 'fluent-booking'),
633 - 'Payment Details' => __('Payment Details', 'fluent-booking'),
634 - 'Item' => __('Item', 'fluent-booking'),
635 - 'Price' => __('Price', 'fluent-booking'),
636 - 'Quantity' => __('Quantity', 'fluent-booking'),
637 - 'Subtotal:' => __('Subtotal:', 'fluent-booking'),
638 - 'Total:' => __('Total:', 'fluent-booking'),
639 - 'Total Payment' => __('Total Payment', 'fluent-booking'),
640 - 'Payment Method' => __('Payment Method', 'fluent-booking'),
641 - 'Pay Now' => __('Pay Now', 'fluent-booking'),
642 - 'processing' => __('Processing', 'fluent-booking'),
643 - 'date_time_config' => DateTimeHelper::getI18nDateTimeConfig(),
644 - 'Country' => __('Country', 'fluent-booking'),
645 - '12h' => _x('12h', 'date time format switch', 'fluent-booking'),
646 - '24h' => _x('24h', 'date time format switch', 'fluent-booking'),
647 - 'spots left' => _x('spots left', 'for how many spots left for available booking', 'fluent-booking'),
648 - 'spots remaining' => _x('spots remaining', 'for how many spots remaining for available booking', 'fluent-booking'),
649 - 'Next' => _x('Next', 'Booking form spot selection', 'fluent-booking'),
650 - 'Select on the Next Step' => __('Select on the Next Step', 'fluent-booking'),
651 - 'location options' => __('location options', 'fluent-booking'),
652 - 'Your address' => __('Your address', 'fluent-booking'),
653 - 'Organizer Phone Number' => __('Organizer Phone Number', 'fluent-booking'),
654 - 'In Person (Attendee Address)' => __('In Person (Attendee Address)', 'fluent-booking'),
655 - 'In Person (Organizer Address)' => __('In Person (Organizer Address)', 'fluent-booking'),
656 - 'Attendee Phone Number' => __('Attendee Phone Number', 'fluent-booking'),
657 - 'Google Meet' => __('Google Meet', 'fluent-booking'),
658 - 'Zoom Meeting' => __('Zoom Meeting', 'fluent-booking'),
659 - 'Online Meeting' => __('Online Meeting', 'fluent-booking'),
660 - 'Phone Call' => __('Phone Call', 'fluent-booking'),
661 - 'Processing...' => __('Processing...', 'fluent-booking'),
662 - 'Loading Payment Processor...' => __('Loading Payment Processor...', 'fluent-booking'),
663 - 'PM' => __('PM', 'fluent-booking'),
664 - 'AM' => __('AM', 'fluent-booking'),
665 - 'Name' => __('Name', 'fluent-booking'),
666 - 'Email' => __('Email', 'fluent-booking'),
667 - 'Date' => __('Date', 'fluent-booking'),
668 - 'Time' => __('Time', 'fluent-booking'),
669 - 'per occurrence' => __('per occurrence', 'fluent-booking'),
670 - 'per guest' => __('per guest', 'fluent-booking'),
671 - 'Add guest' => __('Add guest', 'fluent-booking'),
672 - 'Add guests' => __('Add guests', 'fluent-booking'),
673 - 'Add another' => __('Add another', 'fluent-booking'),
674 - 'Choose File' => __('Choose File', 'fluent-booking'),
675 - 'This field is required.' => __('This field is required.', 'fluent-booking'),
676 - 'No availability in' => __('No availability in', 'fluent-booking'),
677 - 'View next month' => __('View next month', 'fluent-booking'),
678 - 'View previous month' => __('View previous month', 'fluent-booking'),
679 - 'No_payment_method_description' => __('No activated payment method found. If you are an admin please check the event payment settings', 'fluent-booking'),
680 - 'Please fill up the required data' => __('Please fill up the required data', 'fluent-booking'),
681 - 'Please select a valid payment method' => __('Please select a valid payment method', 'fluent-booking'),
682 - 'Please Select' => __('Please Select', 'fluent-booking'),
683 - 'Something is wrong!' => __('Something is wrong!', 'fluent-booking'),
684 - 'Requires Confirmation' => __('Requires Confirmation', 'fluent-booking'),
685 - ],
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 + ]),
686 563 'theme' => Arr::get(get_option('_fluent_booking_settings'), 'theme', 'system-default'),
687 564 'currency_settings' => CurrenciesHelper::getGlobalCurrencySettings()
688 565 ];
689 566
@@ -740,9 +617,9 @@
740 617 'start_date.required' => __('Please select a date and time', 'fluent-booking')
741 618 ];
742 619
743 620 if ($calendarEvent->isPhoneRequired()) {
744 - $rules['phone_number'] = 'required';
621 + $rules['phone_number'] = ['required', $this->validPhoneNumberRule()];
745 622 $messages['phone_number.required'] = __('Please provide your phone number', 'fluent-booking');
746 623 } else if ($calendarEvent->isAddressRequired()) {
747 624 $rules['address'] = 'required';
748 625 $messages['address.required'] = __('Please provide your Address', 'fluent-booking');
@@ -753,12 +630,13 @@
753 630 $selectedLocation = LocationService::getLocationDetails($calendarEvent, Arr::get($postedData, 'location_config', []), $postedData);
754 631 $selectedLocationDriver = Arr::get($selectedLocation, 'type');
755 632 // is user input required
756 633 if (in_array($selectedLocationDriver, ['in_person_guest', 'phone_guest'])) {
757 - $rules['location_config.user_location_input'] = 'required';
758 634 if ($selectedLocationDriver == 'in_person_guest') {
635 + $rules['location_config.user_location_input'] = 'required';
759 636 $messages['location_config.user_location_input.required'] = __('Please provide your address', 'fluent-booking');
760 637 } else {
638 + $rules['location_config.user_location_input'] = ['required', $this->validPhoneNumberRule()];
761 639 $messages['location_config.user_location_input.required'] = __('Please provide your phone number', 'fluent-booking');
762 640 }
763 641 }
764 642 }
@@ -895,10 +773,12 @@
895 773 if (is_wp_error($timeSlotService)) {
896 774 return TimeSlotServiceHandler::sendError($timeSlotService, $calendarEvent, $timezone);
897 775 }
898 776
899 - $availableSpot = $timeSlotService->isSpotAvailable($bookingData['start_time'], $bookingData['end_time'], $duration);
777 + $isSlotLocked = Helper::lockRoundRobinSlot($calendarEvent, $bookingData['start_time'], $bookingData['end_time']);
900 778
779 + $availableSpot = $isSlotLocked ? $timeSlotService->isSpotAvailable($bookingData['start_time'], $bookingData['end_time'], $duration) : false;
780 +
901 781 if (!$availableSpot) {
902 782 wp_send_json([
903 783 'message' => __('This selected time slot is not available. Maybe someone booked the spot just a few seconds ago.', 'fluent-booking')
904 784 ], 422);
@@ -945,8 +825,20 @@
945 825 'booking_hash' => $booking->hash
946 826 ], $booking), 200);
947 827 }
948 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 +
949 841 public function ajaxGetAvailableDates()
950 842 {
951 843 if (!Helper::checkRateLimit('available_dates', 30)) {
952 844 wp_send_json_error(['message' => __('Too many requests. Please try again in a minute.', 'fluent-booking')], 429);
@@ -955,20 +847,30 @@
955 847 $startBenchmark = microtime(true);
956 848
957 849 $request = $_REQUEST; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
958 850
959 - $eventId = (int)$request['event_id'];
851 + $eventId = (int)Arr::get($request, 'event_id');
960 852
961 - $rescheduling = Arr::get($request, 'rescheduling', 'no');
853 + $reschedulingHash = sanitize_text_field(Arr::get($request, 'rescheduling_hash', '')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
962 854
963 - $calendarEvent = CalendarSlot::findOrfail($eventId);
855 + $calendarEvent = $eventId ? CalendarSlot::find($eventId) : null;
964 856
965 - if (!$calendarEvent || ($calendarEvent->status != 'active' && $rescheduling == 'no')) {
857 + if (!$calendarEvent) {
966 858 wp_send_json([
967 859 'message' => __('Sorry, the host is not accepting any new bookings at the moment.', 'fluent-booking')
968 860 ], 422);
969 861 }
970 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 +
971 873 $calendar = $calendarEvent->calendar;
972 874 $startDate = sanitize_text_field(Arr::get($request, 'start_date')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
973 875
974 876 if (!$startDate) {
@@ -1011,8 +913,20 @@
1011 913 }
1012 914
1013 915 public function getCalendarEventVars(Calendar $calendar, CalendarSlot $calendarEvent)
1014 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 +
1015 929 $calendarEvent->description = wpautop($calendarEvent->description);
1016 930 $calendarEvent->location_icon_html = $calendarEvent->defaultLocationHtml();
1017 931 $formFields = BookingFieldService::getBookingFields($calendarEvent);
1018 932
@@ -1023,9 +937,9 @@
1023 937 'min_bookable_date' => $calendarEvent->getMinBookableDateTime(),
1024 938 'is_display_spots' => $calendarEvent->isDisplaySpots(),
1025 939 'duration' => $calendarEvent->getDefaultDuration(),
1026 940 'title' => $calendarEvent->title,
1027 - 'location_settings' => $this->sanitizePublicLocationSettings($calendarEvent->location_settings),
941 + 'location_settings' => LocationService::sanitizePublicLocationSettings($calendarEvent->location_settings),
1028 942 'location_icon_html' => $calendarEvent->location_icon_html,
1029 943 'description' => $calendarEvent->description,
1030 944 'pre_selects' => null,
1031 945 'settings' => $this->sanitizePublicEventSettings($calendarEvent->settings),
@@ -1030,9 +944,9 @@
1030 944 'pre_selects' => null,
1031 945 'settings' => $this->sanitizePublicEventSettings($calendarEvent->settings),
1032 946 'type' => $calendarEvent->type,
1033 947 'event_type' => $calendarEvent->event_type,
1034 - 'time_format' => Arr::get(get_option('_fluent_booking_settings'), 'time_format', '12'),
948 + 'time_format' => $globalConfig['time_format'],
1035 949 ];
1036 950
1037 951 $author = $calendar->getAuthorProfile(true);
1038 952 $author['name'] = $calendar->title;
@@ -1045,13 +959,13 @@
1045 959 'Schedule_Meeting' => __('Schedule Meeting', 'fluent-booking'),
1046 960 'Continue_to_Payments' => __('Continue to Payments', 'fluent-booking'),
1047 961 'Confirm_Payment' => __('Confirm Payment', 'fluent-booking'),
1048 962 ],
1049 - 'date_formatter' => DateTimeHelper::getDateFormatter(true),
1050 - 'isRtl' => Helper::fluentbooking_is_rtl(),
1051 - 'has_pro' => defined('FLUENT_BOOKING_PRO_DIR_FILE'),
1052 - 'duration_lookup' => Helper::getDurationLookup(),
1053 - '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']
1054 968 ];
1055 969
1056 970 $eventVars['form_fields'] = array_values($eventVars['form_fields']);
1057 971
@@ -1059,47 +973,8 @@
1059 973 $eventVars['team_member_profiles'] = $calendarEvent->getAuthorProfiles(true);
1060 974 }
1061 975
1062 976 return apply_filters('fluent_booking/public_event_vars', $eventVars, $calendarEvent);
1063 - }
1064 -
1065 - private function sanitizePublicLocationSettings($locationSettings)
1066 - {
1067 - if (!is_array($locationSettings)) {
1068 - return [];
1069 - }
1070 -
1071 - $safe = [];
1072 - foreach ($locationSettings as $location) {
1073 - if (!is_array($location)) {
1074 - continue;
1075 - }
1076 -
1077 - $type = Arr::get($location, 'type');
1078 - $displayOnBooking = Arr::get($location, 'display_on_booking') === 'yes';
1079 -
1080 - $sanitized = [
1081 - 'type' => $type,
1082 - 'title' => Arr::get($location, 'title'),
1083 - 'display_on_booking' => Arr::get($location, 'display_on_booking', 'no'),
1084 - ];
1085 -
1086 - // Only expose host-private fields when the host explicitly opted
1087 - // in to display them before booking.
1088 - if ($displayOnBooking) {
1089 - if ($type === 'online_meeting') {
1090 - $sanitized['meeting_link'] = Arr::get($location, 'meeting_link');
1091 - } elseif ($type === 'phone_organizer') {
1092 - $sanitized['host_phone_number'] = Arr::get($location, 'host_phone_number');
1093 - } elseif (in_array($type, ['in_person_organizer', 'custom'], true)) {
1094 - $sanitized['description'] = Arr::get($location, 'description');
1095 - }
1096 - }
1097 -
1098 - $safe[] = $sanitized;
1099 - }
1100 -
1101 - return $safe;
1102 977 }
1103 978
1104 979 private function sanitizePublicEventSettings($settings)
1105 980 {