| @@ -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 |
| @@ -163,9 +168,9 @@ | ||
| 163 | 168 | case 'add-booking': |
| 164 | 169 | case 'new': |
| 165 | 170 | case 'new-bookings': |
| 166 | 171 | case 'new-booking': |
| 167 | - $link = 'wpbc-new'; | |
| 172 | + $link = 'wpbc&tab=add-booking'; | |
| 168 | 173 | break; |
| 169 | 174 | |
| 170 | 175 | case 'availability': |
| 171 | 176 | $link = 'wpbc-availability'; |
| @@ -228,8 +233,32 @@ | ||
| 228 | 233 | return wpbc_get_menu_url( 'availability', $is_absolute_url, $is_old ); |
| 229 | 234 | } |
| 230 | 235 | |
| 231 | 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 | +/** | |
| 232 | 261 | * Get URL of Booking > Availability page |
| 233 | 262 | * |
| 234 | 263 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 235 | 264 | * @param boolean $is_old - { default: true } |
| @@ -245,21 +274,101 @@ | ||
| 245 | 274 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 246 | 275 | * @param boolean $is_old - { default: true } |
| 247 | 276 | * @return string - URL to menu |
| 248 | 277 | */ |
| 249 | -function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) { | |
| 250 | - 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 ); | |
| 251 | 360 | } |
| 252 | 361 | |
| 253 | 362 | /** |
| 254 | - * Get URL of Booking > Resources page | |
| 363 | + * Get URL of Booking > Resources > Capacity page | |
| 255 | 364 | * |
| 256 | 365 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 257 | 366 | * @param boolean $is_old - { default: true } |
| 258 | 367 | * @return string - URL to menu |
| 259 | 368 | */ |
| 260 | -function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) { | |
| 261 | - 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'; | |
| 262 | 371 | } |
| 263 | 372 | |
| 264 | 373 | /** |
| 265 | 374 | * Get URL of Booking > Settings page |
| @@ -272,15 +381,54 @@ | ||
| 272 | 381 | return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old ); |
| 273 | 382 | } |
| 274 | 383 | |
| 275 | 384 | /** |
| 276 | - * Get URL of Booking > Setup page | |
| 385 | + * Get URL of Booking > Settings > Calendar page | |
| 277 | 386 | * |
| 278 | 387 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 279 | 388 | * @param boolean $is_old - { default: true } |
| 280 | 389 | * @return string - URL to menu |
| 281 | 390 | */ |
| 282 | -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 ) { | |
| 283 | 431 | return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old ); |
| 284 | 432 | } |
| 285 | 433 | |
| 286 | 434 | |
| @@ -334,16 +482,15 @@ | ||
| 334 | 482 | * |
| 335 | 483 | * @return boolean true | false |
| 336 | 484 | */ |
| 337 | 485 | function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) { |
| 338 | - // Old. | |
| 339 | - // 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 ], 'wpdev-booking.phpwpdev-booking-reservation' ) !== false ) ) { | |
| 341 | - return true; | |
| 486 | + | |
| 487 | + if ( ! is_admin() || empty( $_SERVER[ $server_param ] ) ) { | |
| 488 | + return false; | |
| 342 | 489 | } |
| 343 | - // New. | |
| 344 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 345 | - if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-new' ) !== false ) ) { | |
| 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 ] ) ) { | |
| 346 | 493 | return true; |
| 347 | 494 | } |
| 348 | 495 | |
| 349 | 496 | return false; |
| @@ -349,8 +496,26 @@ | ||
| 349 | 496 | return false; |
| 350 | 497 | } |
| 351 | 498 | |
| 352 | 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 | +/** | |
| 353 | 518 | * Check if this WP Booking Calendar > Settings > Booking Form page |
| 354 | 519 | * |
| 355 | 520 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 356 | 521 | * |
| @@ -355,13 +520,40 @@ | ||
| 355 | 520 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 356 | 521 | * |
| 357 | 522 | * @return boolean true | false |
| 358 | 523 | */ |
| 359 | -function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) { | |
| 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' ) { | |
| 360 | 552 | // Regular user overwrite settings. |
| 361 | 553 | |
| 362 | 554 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 363 | - 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'] ) ) ) ) { | |
| 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'] ) ) ) ) { | |
| 364 | 556 | return true; |
| 365 | 557 | } |
| 366 | 558 | |
| 367 | 559 | return false; |
| @@ -368,19 +560,19 @@ | ||
| 368 | 560 | } |
| 369 | 561 | |
| 370 | 562 | |
| 371 | 563 | /** |
| 372 | - * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page. | |
| 564 | + * Check if this WP Booking Calendar > Settings > Appearance / Theme page | |
| 373 | 565 | * |
| 374 | 566 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 375 | 567 | * |
| 376 | 568 | * @return boolean true | false |
| 377 | 569 | */ |
| 378 | -function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) { | |
| 570 | +function wpbc_is_settings_themes_page( $server_param = 'REQUEST_URI' ) { | |
| 379 | 571 | // Regular user overwrite settings. |
| 380 | 572 | |
| 381 | 573 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 382 | - 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'] ) ) ) ) { | |
| 574 | + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=themes' ) ) ) { | |
| 383 | 575 | return true; |
| 384 | 576 | } |
| 385 | 577 | |
| 386 | 578 | return false; |
| @@ -385,28 +577,58 @@ | ||
| 385 | 577 | |
| 386 | 578 | return false; |
| 387 | 579 | } |
| 388 | 580 | |
| 389 | - | |
| 390 | 581 | /** |
| 391 | - * Check if this WP Booking Calendar > Settings > Booking Form page | |
| 582 | + * Check if this WP Booking Calendar > Settings > Calendar page | |
| 392 | 583 | * |
| 393 | 584 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 394 | 585 | * |
| 395 | 586 | * @return boolean true | false |
| 396 | 587 | */ |
| 397 | -function wpbc_is_settings_color_themes_page( $server_param = 'REQUEST_URI' ) { | |
| 588 | +function wpbc_is_settings_calendar_page( $server_param = 'REQUEST_URI' ) { | |
| 398 | 589 | // Regular user overwrite settings. |
| 399 | 590 | |
| 400 | 591 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 401 | - if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=color_themes' ) ) ) { | |
| 592 | + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=calendar_settings' ) ) ) { | |
| 402 | 593 | return true; |
| 403 | 594 | } |
| 404 | 595 | |
| 405 | 596 | return false; |
| 406 | -} | |
| 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 | +} | |
| 407 | 609 | |
| 408 | 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 | +/** | |
| 409 | 631 | * Check if this Booking > Availability page |
| 410 | 632 | * |
| 411 | 633 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 412 | 634 | * |
| @@ -440,16 +662,20 @@ | ||
| 440 | 662 | return false; |
| 441 | 663 | } |
| 442 | 664 | |
| 443 | 665 | |
| 444 | -/** | |
| 445 | - * Check if this Booking > Setup page | |
| 446 | - * | |
| 447 | - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 448 | - * | |
| 449 | - * @return boolean true | false | |
| 450 | - */ | |
| 451 | -function wpbc_is_setup_wizard_page( $server_param = 'REQUEST_URI' ) { // FixIn: 9.8.0.1. | |
| 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. | |
| 452 | 678 | |
| 453 | 679 | // New. |
| 454 | 680 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 455 | 681 | if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) { |
| @@ -455,12 +681,12 @@ | ||
| 455 | 681 | if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) { |
| 456 | 682 | return true; |
| 457 | 683 | } |
| 458 | 684 | |
| 459 | - return false; | |
| 460 | -} | |
| 461 | - | |
| 462 | -/** | |
| 685 | + return false; | |
| 686 | +} | |
| 687 | + | |
| 688 | +/** | |
| 463 | 689 | * Check if this Booking > Resources page |
| 464 | 690 | * |
| 465 | 691 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 466 | 692 | * |