| @@ -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 |
| @@ -409,15 +414,21 @@ | ||
| 409 | 414 | return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=form_messages'; |
| 410 | 415 | } |
| 411 | 416 | |
| 412 | 417 | /** |
| 413 | - * Get URL of Booking > Setup page | |
| 414 | - * | |
| 415 | - * @param boolean $is_absolute_url - Absolute or relative url { default: true } | |
| 416 | - * @param boolean $is_old - { default: true } | |
| 417 | - * @return string - URL to menu | |
| 418 | - */ | |
| 419 | -function wpbc_get_setup_wizard_page_url( $is_absolute_url = true, $is_old = true ) { | |
| 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 ) { | |
| 420 | 431 | return wpbc_get_menu_url( 'setup', $is_absolute_url, $is_old ); |
| 421 | 432 | } |
| 422 | 433 | |
| 423 | 434 | |
| @@ -651,16 +662,20 @@ | ||
| 651 | 662 | return false; |
| 652 | 663 | } |
| 653 | 664 | |
| 654 | 665 | |
| 655 | -/** | |
| 656 | - * Check if this Booking > Setup page | |
| 657 | - * | |
| 658 | - * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 659 | - * | |
| 660 | - * @return boolean true | false | |
| 661 | - */ | |
| 662 | -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. | |
| 663 | 678 | |
| 664 | 679 | // New. |
| 665 | 680 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 666 | 681 | if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) { |
| @@ -666,12 +681,12 @@ | ||
| 666 | 681 | if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-setup' ) !== false ) ) { |
| 667 | 682 | return true; |
| 668 | 683 | } |
| 669 | 684 | |
| 670 | - return false; | |
| 671 | -} | |
| 672 | - | |
| 673 | -/** | |
| 685 | + return false; | |
| 686 | +} | |
| 687 | + | |
| 688 | +/** | |
| 674 | 689 | * Check if this Booking > Resources page |
| 675 | 690 | * |
| 676 | 691 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 677 | 692 | * |