PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
← All changes | includes/_functions/admin_menu_url.php +387 -42 10.10.1 → 11.9 View file →
@@ -1,4 +1,4 @@
1 1 <?php
2 2 /**
3 3 * @version 1.0
4 4 * @package Booking Calendar
@@ -59,27 +59,32 @@
59 59
60 60 return $maybe_absolute_link;
61 61 }
62 62
63 -/**
64 - * Get Absolute URL (check for languages)
65 - *
66 - * @param $maybe_relative_link
67 - *
68 - * @return string
69 - */
70 -function wpbc_make_link_absolute( $maybe_relative_link ){
63 +/**
64 + * Convert a relative front-end path to an absolute language-aware URL.
65 + *
66 + * The path is passed through WordPress so multilingual URL filters can apply
67 + * the current language directory or domain without introducing duplicate
68 + * path separators.
69 + *
70 + * @param string $maybe_relative_link Relative or absolute front-end URL.
71 + *
72 + * @return string JavaScript-safe absolute URL.
73 + */
74 +function wpbc_make_link_absolute( $maybe_relative_link ){
75 +
76 + if ( ( $maybe_relative_link != home_url() ) && ( strpos( $maybe_relative_link, 'http' ) !== 0 ) ) {
77 +
78 + $maybe_relative_link = wpbc_lang( $maybe_relative_link ); // FixIn: 8.4.5.1.
79 +
80 + $relative_path = trim( wp_make_link_relative( $maybe_relative_link ), '/' );
81 + $maybe_relative_link = home_url( '/' . $relative_path );
82 + }
83 +
84 + return esc_js( $maybe_relative_link );
85 +}
71 86
72 - if ( ( $maybe_relative_link != home_url() ) && ( strpos( $maybe_relative_link, 'http' ) !== 0 ) ) {
73 -
74 - $maybe_relative_link = wpbc_lang( $maybe_relative_link ); // FixIn: 8.4.5.1.
75 -
76 - $maybe_relative_link = home_url() . '/' . trim( wp_make_link_relative( $maybe_relative_link ), '/' ); // FixIn: 7.0.1.20.
77 - }
78 -
79 - return esc_js( $maybe_relative_link );
80 -}
81 -
82 87 /**
83 88 * Redirect browser to a specific page
84 89 *
85 90 * @param string $url - URL of page to redirect
@@ -112,14 +117,20 @@
112 117 function wpbc_is_on_edit_page() {
113 118
114 119 // FixIn: 9.9.0.39.
115 120
121 + // Elementor.
122 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
123 + if ( ( ! empty( $_REQUEST['action'] ) ) && ( ( 'elementor' === $_REQUEST['action'] ) || ( 'elementor_ajax' === $_REQUEST['action'] ) ) ) {
124 + return false;
125 + }
126 +
116 127 if ( ( ! empty( $GLOBALS['pagenow'] ) ) && ( is_admin() ) ) {
117 128 if (
118 129 ( 'post.php' === $GLOBALS['pagenow'] ) // Edit - Post / Page.
119 130 || ( 'post-new.php' === $GLOBALS['pagenow'] ) // Add New - Post / Page.
120 131 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
121 - || ( ( 'admin-ajax.php' === $GLOBALS['pagenow'] ) && ( ! empty( $_REQUEST['action'] ) ) && ( 'elementor_ajax' === $_REQUEST['action'] ) ) // Elementor Edit page - Ajax.
132 + // || ( ( 'admin-ajax.php' === $GLOBALS['pagenow'] ) && ( ! empty( $_REQUEST['action'] ) ) && ( 'elementor_ajax' === $_REQUEST['action'] ) ) // Elementor Edit page - Ajax.
122 133 ) {
123 134 return true;
124 135 }
125 136 }
@@ -157,9 +168,9 @@
157 168 case 'add-booking':
158 169 case 'new':
159 170 case 'new-bookings':
160 171 case 'new-booking':
161 - $link = 'wpbc-new';
172 + $link = 'wpbc&tab=add-booking';
162 173 break;
163 174
164 175 case 'availability':
165 176 $link = 'wpbc-availability';
@@ -222,8 +233,32 @@
222 233 return wpbc_get_menu_url( 'availability', $is_absolute_url, $is_old );
223 234 }
224 235
225 236 /**
237 + * Get URL of Booking > Availability > General Availability page.
238 + *
239 + * @param boolean $is_absolute_url Absolute or relative url { default: true }.
240 + * @param boolean $is_old Legacy compatibility flag.
241 + *
242 + * @return string URL to General Availability page.
243 + */
244 +function wpbc_get_general_availability_url( $is_absolute_url = true, $is_old = true ) {
245 + return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=general_availability';
246 +}
247 +
248 +/**
249 + * Get URL of Booking > Availability > Time Slots Availability page.
250 + *
251 + * @param boolean $is_absolute_url Absolute or relative url { default: true }.
252 + * @param boolean $is_old Legacy compatibility flag.
253 + *
254 + * @return string URL to Time Slots Availability page.
255 + */
256 +function wpbc_get_time_slots_availability_url( $is_absolute_url = true, $is_old = true ) {
257 + return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=time_slots_availability';
258 +}
259 +
260 +/**
226 261 * Get URL of Booking > Availability page
227 262 *
228 263 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
229 264 * @param boolean $is_old - { default: true }
@@ -239,21 +274,101 @@
239 274 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
240 275 * @param boolean $is_old - { default: true }
241 276 * @return string - URL to menu
242 277 */
243 -function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) {
244 - return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old );
278 +function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) {
279 + return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old );
280 +}
281 +
282 +/**
283 + * Get the normalized administrator edit-booking destination.
284 + *
285 + * Existing installations and malformed stored values retain the popup workflow.
286 + * The optional argument keeps normalization independently testable without
287 + * changing a saved WordPress option.
288 + *
289 + * @param null|string $stored_mode Optional stored mode. Null loads the site option.
290 + *
291 + * @return string Either `popup` or `add_booking_page`.
292 + */
293 +function wpbc_get_booking_admin_edit_mode( $stored_mode = null ) {
294 +
295 + if ( null === $stored_mode ) {
296 + $stored_mode = get_bk_option( 'booking_admin_edit_booking_mode' );
297 + }
298 +
299 + $stored_mode = sanitize_key( (string) $stored_mode );
300 +
301 + return in_array( $stored_mode, array( 'popup', 'add_booking_page' ), true ) ? $stored_mode : 'popup';
302 +}
303 +
304 +/**
305 + * Check whether administrator edit links should open the dedicated Add Booking page.
306 + *
307 + * @param null|string $stored_mode Optional stored mode used for independent testing.
308 + *
309 + * @return bool True for the dedicated page; false for the default popup.
310 + */
311 +function wpbc_is_booking_admin_edit_page_enabled( $stored_mode = null ) {
312 + return 'add_booking_page' === wpbc_get_booking_admin_edit_mode( $stored_mode );
313 +}
314 +
315 +/**
316 + * Build the authorized administrator URL for editing one Booking on Add Booking.
317 + *
318 + * The destination page retains its existing capability, MultiUser ownership,
319 + * Booking hash, Resource, and Booking Form checks. This helper only centralizes
320 + * the released URL contract used by Booking Listing and Timeline links.
321 + *
322 + * @param int $resource_id Booking Resource ID.
323 + * @param string $booking_hash Booking edit hash.
324 + * @param string $booking_form Optional custom Booking Form name.
325 + *
326 + * @return string Sanitized Add Booking edit URL, or an empty string when required values are missing.
327 + */
328 +function wpbc_get_booking_admin_edit_url( $resource_id, $booking_hash, $booking_form = '' ) {
329 +
330 + $resource_id = absint( $resource_id );
331 + $booking_hash = sanitize_text_field( (string) $booking_hash );
332 + $booking_form = sanitize_text_field( (string) $booking_form );
333 +
334 + if ( $resource_id < 1 || '' === $booking_hash ) {
335 + return '';
336 + }
337 +
338 + $query_args = array(
339 + 'booking_type' => $resource_id,
340 + 'booking_hash' => $booking_hash,
341 + 'parent_res' => 1,
342 + );
343 +
344 + if ( '' !== $booking_form ) {
345 + $query_args['booking_form'] = $booking_form;
346 + }
347 +
348 + return esc_url_raw( add_query_arg( $query_args, wpbc_get_new_booking_url( true, false ) ) );
349 +}
350 +
351 +/**
352 + * Get URL of Booking > Resources page
353 + *
354 + * @param boolean $is_absolute_url - Absolute or relative url { default: true }
355 + * @param boolean $is_old - { default: true }
356 + * @return string - URL to menu
357 + */
358 +function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) {
359 + return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old );
245 360 }
246 361
247 362 /**
248 - * Get URL of Booking > Resources page
363 + * Get URL of Booking > Resources > Capacity page
249 364 *
250 365 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
251 366 * @param boolean $is_old - { default: true }
252 367 * @return string - URL to menu
253 368 */
254 -function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) {
255 - return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old );
369 +function wpbc_get_resource_capacity_url( $is_absolute_url = true, $is_old = true ) {
370 + return wpbc_get_resources_url( $is_absolute_url, $is_old ) . '&tab=capacity';
256 371 }
257 372
258 373 /**
259 374 * Get URL of Booking > Settings page
@@ -266,15 +381,54 @@
266 381 return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old );
267 382 }
268 383
269 384 /**
270 - * Get URL of Booking > Setup page
385 + * Get URL of Booking > Settings > Calendar page
271 386 *
272 387 * @param boolean $is_absolute_url - Absolute or relative url { default: true }
273 388 * @param boolean $is_old - { default: true }
274 389 * @return string - URL to menu
275 390 */
276 -function wpbc_get_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) {
391 +function wpbc_get_settings_calendar_url( $is_absolute_url = true, $is_old = true ) {
392 + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=calendar_settings';
393 +}
394 +
395 +/**
396 + * Get URL of Booking > Settings > Appearance / Theme page
397 + *
398 + * @param boolean $is_absolute_url - Absolute or relative url { default: true }
399 + * @param boolean $is_old - { default: true }
400 + * @return string - URL to menu
401 + */
402 +function wpbc_get_settings_themes_url( $is_absolute_url = true, $is_old = true ) {
403 + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=themes';
404 +}
405 +
406 +/**
407 + * Get URL of Booking > Settings > Form Messages page.
408 + *
409 + * @param boolean $is_absolute_url Absolute or relative URL.
410 + * @param boolean $is_old Legacy menu URL style.
411 + * @return string
412 + */
413 +function wpbc_get_settings_messages_url( $is_absolute_url = true, $is_old = true ) {
414 + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=form_messages';
415 +}
416 +
417 +/**
418 + * Get the canonical production Setup Wizard URL.
419 + *
420 + * Opening this URL never restarts or completes a checkpoint. The page resumes
421 + * an active checkpoint, starts Welcome when no checkpoint exists, or renders
422 + * Setup overview when the checkpoint is complete. A new setup is an explicit,
423 + * nonce-protected action from Setup overview.
424 + *
425 + * @param bool $is_absolute_url Whether to return an absolute administration URL.
426 + * @param bool $is_old Retained compatibility argument; ignored by the native menu URL builder.
427 + *
428 + * @return string Canonical Setup Wizard URL.
429 + */
430 +function wpbc_get_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) {
277 431 return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old );
278 432 }
279 433
280 434
@@ -288,8 +442,25 @@
288 442 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
289 443 *
290 444 * @return boolean true | false
291 445 */
446 +function wpbc_is_this_plugin_page( $server_param = 'REQUEST_URI' ) {
447 +
448 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
449 + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) ) {
450 + return true;
451 + }
452 +
453 + return false;
454 +}
455 +
456 +/**
457 + * Check if this Booking Listing or Calendar Overview page
458 + *
459 + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
460 + *
461 + * @return boolean true | false
462 + */
292 463 function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) {
293 464 // Old.
294 465 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
295 466 if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) === false ) ) {
@@ -311,16 +482,97 @@
311 482 *
312 483 * @return boolean true | false
313 484 */
314 485 function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) {
315 - // Old.
486 +
487 + if ( ! is_admin() || empty( $_SERVER[ $server_param ] ) ) {
488 + return false;
489 + }
490 +
491 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
492 + if ( wpbc_is_new_booking_page_url( $_SERVER[ $server_param ] ) ) {
493 + return true;
494 + }
495 +
496 + return false;
497 +}
498 +
499 +/**
500 + * Check if a URL points to Booking > Bookings > Add booking.
501 + *
502 + * @param string $request_uri URL or request URI.
503 + *
504 + * @return bool
505 + */
506 +function wpbc_is_new_booking_page_url( $request_uri ) {
507 +
508 + $request_uri = (string) $request_uri;
509 +
510 + return (
511 + ( false !== strpos( $request_uri, 'page=wpbc' ) )
512 + && ( false === strpos( $request_uri, 'page=wpbc-' ) )
513 + && ( false !== strpos( $request_uri, 'tab=add-booking' ) )
514 + );
515 +}
516 +
517 +/**
518 + * Check if this WP Booking Calendar > Settings > Booking Form page
519 + *
520 + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
521 + *
522 + * @return boolean true | false
523 + */
524 +function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
525 + // Regular user overwrite settings.
526 +
527 + // Match the legacy `form` tab exactly. A substring check also matched newer
528 + // tabs whose names start with `form`, such as `form_messages`.
529 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
530 + $request_uri = ! empty( $_SERVER[ $server_param ] ) ? (string) $_SERVER[ $server_param ] : '';
531 + $is_form_tab = (bool) preg_match( '/(?:[?&])tab=form(?:&|$)/', $request_uri );
532 +
533 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
534 + $is_multiuser_form_tab = class_exists( 'wpdev_bk_multiuser' ) && ! empty( $_REQUEST['tab'] ) && 'form' === $_REQUEST['tab'];
535 +
536 + if ( is_admin() && false !== strpos( $request_uri, 'page=wpbc-settings' ) && ( $is_form_tab || $is_multiuser_form_tab ) ) {
537 + return true;
538 + }
539 +
540 + return false;
541 +}
542 +
543 +
544 +/**
545 + * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page.
546 + *
547 + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
548 + *
549 + * @return boolean true | false
550 + */
551 +function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) {
552 + // Regular user overwrite settings.
553 +
316 554 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
317 - if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) !== false ) ) {
555 + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( ( strpos( $_SERVER[ $server_param ], '&tab=builder_booking_form' ) !== false ) || ( ( class_exists( 'wpdev_bk_multiuser' ) ) && ( ! empty( $_REQUEST['tab'] ) ) && ( 'builder_booking_form' === $_REQUEST['tab'] ) ) ) ) {
318 556 return true;
319 557 }
320 - // New.
558 +
559 + return false;
560 +}
561 +
562 +
563 +/**
564 + * Check if this WP Booking Calendar > Settings > Appearance / Theme page
565 + *
566 + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
567 + *
568 + * @return boolean true | false
569 + */
570 +function wpbc_is_settings_themes_page( $server_param = 'REQUEST_URI' ) {
571 + // Regular user overwrite settings.
572 +
321 573 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
322 - if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-new' ) !== false ) ) {
574 + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=themes' ) ) ) {
323 575 return true;
324 576 }
325 577
326 578 return false;
@@ -326,26 +578,57 @@
326 578 return false;
327 579 }
328 580
329 581 /**
330 - * Check if this WP Booking Calendar > Settings > Booking Form page
582 + * Check if this WP Booking Calendar > Settings > Calendar page
331 583 *
332 584 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
333 585 *
334 586 * @return boolean true | false
335 587 */
336 -function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) {
588 +function wpbc_is_settings_calendar_page( $server_param = 'REQUEST_URI' ) {
337 589 // Regular user overwrite settings.
338 590
339 591 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
340 - if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( ( strpos( $_SERVER[ $server_param ], '&tab=form' ) !== false ) || ( ( class_exists( 'wpdev_bk_multiuser' ) ) && ( ! empty( $_REQUEST['tab'] ) ) && ( 'form' === $_REQUEST['tab'] ) ) ) ) {
592 + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=calendar_settings' ) ) ) {
341 593 return true;
342 594 }
343 595
344 596 return false;
345 -}
597 +}
598 +
599 +/**
600 + * Check if this is WP Booking Calendar > Settings > Form Messages.
601 + *
602 + * @param string $server_param Server URL parameter.
603 + * @return boolean
604 + */
605 +function wpbc_is_settings_messages_page( $server_param = 'REQUEST_URI' ) {
606 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
607 + return is_admin() && ! empty( $_SERVER[ $server_param ] ) && false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) && false !== strpos( $_SERVER[ $server_param ], '&tab=form_messages' );
608 +}
346 609
347 610 /**
611 + * Check if this admin page renders a real front-end booking form or calendar preview.
612 + *
613 + * @return boolean true | false
614 + */
615 +function wpbc_is_admin_page_with_frontend_booking_preview() {
616 +
617 + return (
618 + wpbc_is_new_booking_page()
619 + || wpbc_is_settings_form_page()
620 + || wpbc_is_settings_themes_page()
621 + || wpbc_is_settings_calendar_page()
622 + || wpbc_is_settings_messages_page()
623 + || wpbc_is_setup_wizard_page()
624 + || wpbc_is_builder_booking_form_page()
625 + || ( function_exists( 'wpbc_add_appointment_page_is_active' ) && wpbc_add_appointment_page_is_active() )
626 + || ( function_exists( 'wpbc_is_add_booking_modal_on_booking_listing_page' ) && wpbc_is_add_booking_modal_on_booking_listing_page() )
627 + );
628 +}
629 +
630 +/**
348 631 * Check if this Booking > Availability page
349 632 *
350 633 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
351 634 *
@@ -361,21 +644,19 @@
361 644
362 645 return false;
363 646 }
364 647
365 -
366 648 /**
367 - * Check if this Booking > Setup page
649 + * Check if this Booking > Availability page
368 650 *
369 651 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
370 652 *
371 653 * @return boolean true | false
372 654 */
373 -function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1.
655 +function wpbc_is_builder_booking_form_page( $server_param = 'REQUEST_URI' ) {
374 656
375 - // New.
376 657 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
377 - if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) {
658 + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'tab=builder_booking_form' ) !== false ) ) {
378 659 return true;
379 660 }
380 661
381 662 return false;
@@ -380,9 +661,32 @@
380 661
381 662 return false;
382 663 }
383 664
384 -/**
665 +
666 +/**
667 + * Check whether the current administration URL belongs to a Booking Calendar setup route.
668 + *
669 + * The prefix match is intentional because the canonical route and its hidden
670 + * compatibility alias share the same stable setup prefix.
671 + *
672 + * @param string $server_param Server field to inspect. Expected values are
673 + * `REQUEST_URI` or `HTTP_REFERER`.
674 + *
675 + * @return bool True for any Booking Calendar setup route; otherwise false.
676 + */
677 +function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1.
678 +
679 + // New.
680 + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
681 + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) {
682 + return true;
683 + }
684 +
685 + return false;
686 +}
687 +
688 +/**
385 689 * Check if this Booking > Resources page
386 690 *
387 691 * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI'
388 692 *
@@ -486,5 +790,46 @@
486 790 $url = esc_url_raw( $url ); // FixIn: 8.1.1.7.
487 791 }
488 792
489 793 return $url;
490 -}
794 +}
795 +
796 +
797 +function wpbc_left_vertival_nav__get_tab_url( $page_tag, $tab_name, $subtab_name = false, $tags = array( 'tab' => 'tab', 'subtab' => 'subtab' ) ) {
798 +
799 + if ( false === $subtab_name ) {
800 + return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, ), 'admin.php' ) ) );
801 + } else {
802 + return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, $tags['subtab'] => $subtab_name, ), 'admin.php' ) ) );
803 + }
804 +}
805 +
806 +/**
807 + * Get back URL for going from edit season filter or rate to specfic main page.
808 + *
809 + * @return string|null
810 + */
811 +function wpbc_get_back_button_url__for_seasons() {
812 +
813 + $page_params_arr = array(
814 + 'page' => 'wpbc-availability',
815 + 'page_num' => 1,
816 + );
817 +
818 + if ( ! empty( $_REQUEST['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
819 + $page_params_arr['page'] = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
820 + }
821 + if ( ! empty( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
822 + $page_params_arr['tab'] = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
823 + }
824 + if ( ! empty( $_REQUEST['page_num'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
825 + $page_params_arr['page_num'] = intval( $_REQUEST['page_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
826 + }
827 +
828 + $back_url = admin_url(
829 + add_query_arg(
830 + $page_params_arr,
831 + 'admin.php'
832 + )
833 + );
834 + return $back_url;
835 +}