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/LandingPage/LandingPageHandler.php +46 -22 1.7.1 → 2.5.0 View file →
@@ -12,8 +12,9 @@
12 12 use FluentBooking\App\Services\BookingService;
13 13 use FluentBooking\App\Services\Helper;
14 14 use FluentBooking\Framework\Support\Arr;
15 15 use FluentBooking\Framework\Support\Collection;
16 +use FluentBooking\App\Vite;
16 17
17 18 class LandingPageHandler
18 19 {
19 20 public function boot()
@@ -39,15 +40,23 @@
39 40 }
40 41
41 42 $authorSlug = sanitize_text_field($urlParts[1]);
42 43
44 + if (isset($_GET['embedded'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
45 + $this->handleEmbeddedStyle();
46 + }
47 +
43 48 $this->routeView($authorSlug, Arr::get($urlParts, 2, null));
44 49 }
45 50
46 51 public function handleUrlParamsPage()
47 52 {
48 - $route = sanitize_text_field($_GET['fluent-booking']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
53 + $route = isset($_GET['fluent-booking']) ? sanitize_text_field(wp_unslash($_GET['fluent-booking'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
49 54
55 + if (isset($_GET['embedded'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
56 + $this->handleEmbeddedStyle();
57 + }
58 +
50 59 if ($route == 'booking') {
51 60 $this->handleAfterBookingPage();
52 61 return;
53 62 }
@@ -90,9 +99,9 @@
90 99 ->first();
91 100 if (!$slot) {
92 101 return;
93 102 }
94 - $this->renderBookingView($calendar, $slot);
103 + return $this->renderBookingView($calendar, $slot);
95 104 }
96 105
97 106 $this->renderHostView($calendar);
98 107 }
@@ -103,9 +112,9 @@
103 112 $settings = LandingPageHelper::getSettings($calendar, 'public');
104 113
105 114 $activeEvents = CalendarSlot::where('calendar_id', $calendar->id)
106 115 ->where('status', 'active');
107 -
116 +
108 117 if ($settings['show_type'] != 'all') {
109 118 $activeEvents = $activeEvents->whereIn('id', $settings['enabled_slots']);
110 119 }
111 120
@@ -145,9 +154,8 @@
145 154 $activeEvent->locations = $activeEvent->defaultLocationHtml();
146 155 do_action_ref_array('fluent_booking/landing_page_event', [&$activeEvent]);
147 156 }
148 157
149 - $assetUrl = App::getInstance('url.assets');
150 158 $data = [
151 159 'calendar' => $calendar,
152 160 'events' => $activeEvents,
153 161 'author' => $authorProfile,
@@ -153,17 +161,18 @@
153 161 'author' => $authorProfile,
154 162 'title' => $calendar->title .' - '.get_bloginfo('name'),
155 163 'description' => $metaDescription,
156 164 'url' => home_url($wp->request),
165 + 'embedded' => isset($_GET['embedded']) ? true : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
157 166 'css_files' => [
158 - App::getInstance('url.assets') . 'public/saas.css'
167 + Vite::styleUrl('saas_css')
159 168 ],
160 169 'js_files' => [
161 - 'fluent-booking-public-js' => $assetUrl . 'public/js/app.js',
170 + 'fluent-booking-public-js' => Vite::scriptUrl('public_app'),
162 171 ],
163 172 'js_vars' => $jsVars,
164 173 'header_js_files' => [
165 - 'fluent_booking_team_app-js' => $assetUrl. 'public/js/team_app.js'
174 + 'fluent_booking_team_app-js' => Vite::scriptUrl('team_app')
166 175 ]
167 176 ];
168 177
169 178 if ($extraJsFiles) {
@@ -171,9 +180,9 @@
171 180 $data['js_files'] = array_merge($data['js_files'], $extraJsFiles);
172 181 }
173 182
174 183 $data = apply_filters('fluent_booking/host_view_page_vars', $data, $calendar, $activeEvents, $authorProfile);
175 -
184 +
176 185 $app = App::getInstance();
177 186 status_header(200);
178 187 $app->view->render('landing.author_landing', $data);
179 188 exit(200);
@@ -195,9 +204,9 @@
195 204 $calendarEvent->max_lookup_date = $calendarEvent->getMaxLookUpDate();
196 205 $calendarEvent->min_lookup_date = $calendarEvent->getMinLookUpDate();
197 206
198 207 if (!empty($_REQUEST['booking_id'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
199 - $bookingHash = sanitize_text_field($_REQUEST['booking_id']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
208 + $bookingHash = sanitize_text_field(wp_unslash($_REQUEST['booking_id'])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
200 209 $booking = Booking::where('hash', $bookingHash)
201 210 ->where('event_id', $calendarEvent->id)
202 211 ->first();
203 212 if ($booking) {
@@ -219,12 +228,10 @@
219 228 $assetUrl = App::getInstance('url.assets');
220 229
221 230 $eventVars = (new FrontEndHandler())->getCalendarEventVars($calendar, $calendarEvent);
222 231
223 - $isRtl = Helper::fluentbooking_is_rtl();
232 + $publicCss = 'saas_css';
224 233
225 - $publicCss = $isRtl ? 'public/saas-rtl.css' : 'public/saas.css';
226 -
227 234 $title = $calendarEvent->title . ' ' . __('with', 'fluent-booking') . ' ' . $authorProfile['name'];
228 235
229 236 $title = apply_filters('fluent_booking/booking_confirmation_page_title', $title, $calendarEvent, $authorProfile);
230 237
@@ -234,13 +241,14 @@
234 241 'author' => $authorProfile,
235 242 'title' => $title,
236 243 'description' => substr(strip_shortcodes(wp_strip_all_tags(str_replace(PHP_EOL, ' ', $calendarEvent->description))), 0, 300) . '...',
237 244 'url' => home_url($wp->request),
245 + 'embedded' => isset($_GET['embedded']) ? true : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
238 246 'css_files' => [
239 - $assetUrl . $publicCss
247 + Vite::styleUrl($publicCss)
240 248 ],
241 249 'js_files' => [
242 - 'fluent-booking-public-js' => $assetUrl . 'public/js/app.js',
250 + 'fluent-booking-public-js' => Vite::scriptUrl('public_app'),
243 251 ],
244 252 'js_vars' => [
245 253 'fluentCalendarPublicVars' => (new FrontEndHandler())->getGlobalVars(),
246 254 'fcal_public_vars_' . $calendar->id . '_' . $calendarEvent->id => $eventVars,
@@ -304,12 +312,9 @@
304 312 $responseHtml = BookingService::getBookingConfirmationHtml($booking, $actionType);
305 313
306 314 $authorProfile = $calendarEvent->getAuthorProfile(true);
307 315
308 - $publicCss = 'public/saas_public.css';
309 - if (Helper::fluentbooking_is_rtl()) {
310 - $publicCss = 'public/saas_public-rtl.css';
311 - }
316 + $publicCss = 'saas_public_css';
312 317
313 318 $data = [
314 319 'title' => __('Confirmation: ', 'fluent-booking') . $calendarEvent->title . ' ' . __('with', 'fluent-booking') . ' ' . $authorProfile['name'],
315 320 'body' => $responseHtml,
@@ -314,9 +319,9 @@
314 319 'title' => __('Confirmation: ', 'fluent-booking') . $calendarEvent->title . ' ' . __('with', 'fluent-booking') . ' ' . $authorProfile['name'],
315 320 'body' => $responseHtml,
316 321 'description' => substr(strip_shortcodes(wp_strip_all_tags(str_replace(PHP_EOL, ' ', $calendarEvent->description))), 0, 300) . '...',
317 322 'css_files' => [
318 - App::getInstance('url.assets') . $publicCss
323 + Vite::styleUrl($publicCss)
319 324 ],
320 325 'js_files' => [],
321 326 'js_vars' => [],
322 327 'author' => $authorProfile,
@@ -322,8 +327,9 @@
322 327 'author' => $authorProfile,
323 328 'slot' => $calendarEvent,
324 329 'url' => home_url($wp->request),
325 330 'action_type' => $actionType,
331 + 'embedded' => isset($_GET['embedded']) ? true : false, // phpcs:ignore WordPress.Security.NonceVerification.Recommended
326 332 'theme' => Arr::get(get_option('_fluent_booking_settings'), 'theme','system-default'),
327 333 'back_button' => [
328 334 'show' => true,
329 335 'text' => __('Back to home', 'fluent-booking'),
@@ -331,9 +337,9 @@
331 337 ]
332 338 ];
333 339
334 340 if ($actionType == 'cancel') {
335 - $data['js_files']['fluent-booking-public-manage-meeting-js'] = App::getInstance('url.assets') . 'public/js/public-manage-meeting.js';
341 + $data['js_files']['fluent-booking-public-manage-meeting-js'] = Vite::scriptUrl('manage_meeting');
336 342 }
337 343
338 344 $data = apply_filters('fluent_booking/booking_confirmation_page_vars', $data, $booking, $calendarEvent);
339 345
@@ -344,9 +350,9 @@
344 350 }
345 351
346 352 private function handleAfterBookingPage()
347 353 {
348 - $bookingHash = sanitize_text_field(Arr::get($_REQUEST, 'meeting_hash')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
354 + $bookingHash = sanitize_text_field(wp_unslash(Arr::get($_REQUEST, 'meeting_hash'))); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
349 355 if (!$bookingHash) {
350 356 return;
351 357 }
352 358
@@ -428,8 +434,26 @@
428 434
429 435 $this->renderBookingView($booking->calendar, $booking->calendar_event, $booking, true);
430 436 }
431 437
438 + private function handleEmbeddedStyle()
439 + {
440 + add_action('wp_print_styles', function () {
441 + global $wp_styles;
442 + if($wp_styles) {
443 + foreach ($wp_styles->queue as $style) {
444 + $src = $wp_styles->registered[$style]->src;
445 + if (
446 + (strpos($src, 'fluentbooking') === false) &&
447 + (strpos($src, 'fluent_booking') === false)
448 + ) {
449 + wp_dequeue_style($wp_styles->registered[$style]->handle);
450 + }
451 + }
452 + }
453 + }, 100);
454 + }
455 +
432 456 public function getEventLandingExtraJsFiles($formFields, $calendarEvent)
433 457 {
434 458 $files = [];
435 459 $assetUrl = App::getInstance('url.assets');
@@ -434,9 +458,9 @@
434 458 $files = [];
435 459 $assetUrl = App::getInstance('url.assets');
436 460
437 461 if (BookingFieldService::hasPhoneNumberField($formFields)) {
438 - $files['fluent-booking-phone-field-js'] = $assetUrl . 'public/js/phone-field.js';
462 + $files['fluent-booking-phone-field-js'] = Vite::scriptUrl('phone_field');
439 463 }
440 464
441 465 if ($calendarEvent->type == 'paid') {
442 466 $files['fluent-booking-checkout-sdk-stripe-js'] = 'https://js.stripe.com/v3/';