| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @version 1.0 |
| 4 | 4 | * @package Booking Calendar |
| @@ -112,14 +112,20 @@ | ||
| 112 | 112 | function wpbc_is_on_edit_page() { |
| 113 | 113 | |
| 114 | 114 | // FixIn: 9.9.0.39. |
| 115 | 115 | |
| 116 | + // Elementor. | |
| 117 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 118 | + if ( ( ! empty( $_REQUEST['action'] ) ) && ( ( 'elementor' === $_REQUEST['action'] ) || ( 'elementor_ajax' === $_REQUEST['action'] ) ) ) { | |
| 119 | + return false; | |
| 120 | + } | |
| 121 | + | |
| 116 | 122 | if ( ( ! empty( $GLOBALS['pagenow'] ) ) && ( is_admin() ) ) { |
| 117 | 123 | if ( |
| 118 | 124 | ( 'post.php' === $GLOBALS['pagenow'] ) // Edit - Post / Page. |
| 119 | 125 | || ( 'post-new.php' === $GLOBALS['pagenow'] ) // Add New - Post / Page. |
| 120 | 126 | // 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. | |
| 127 | + // || ( ( 'admin-ajax.php' === $GLOBALS['pagenow'] ) && ( ! empty( $_REQUEST['action'] ) ) && ( 'elementor_ajax' === $_REQUEST['action'] ) ) // Elementor Edit page - Ajax. | |
| 122 | 128 | ) { |
| 123 | 129 | return true; |
| 124 | 130 | } |
| 125 | 131 | } |
| @@ -157,9 +163,9 @@ | ||
| 157 | 163 | case 'add-booking': |
| 158 | 164 | case 'new': |
| 159 | 165 | case 'new-bookings': |
| 160 | 166 | case 'new-booking': |
| 161 | - $link = 'wpbc-new'; | |
| 167 | + $link = 'wpbc&tab=add-booking'; | |
| 162 | 168 | break; |
| 163 | 169 | |
| 164 | 170 | case 'availability': |
| 165 | 171 | $link = 'wpbc-availability'; |
| @@ -222,8 +228,32 @@ | ||
| 222 | 228 | return wpbc_get_menu_url( 'availability', $is_absolute_url, $is_old ); |
| 223 | 229 | } |
| 224 | 230 | |
| 225 | 231 | /** |
| 232 | + * Get URL of Booking > Availability > General Availability page. | |
| 233 | + * | |
| 234 | + * @param boolean $is_absolute_url Absolute or relative url { default: true }. | |
| 235 | + * @param boolean $is_old Legacy compatibility flag. | |
| 236 | + * | |
| 237 | + * @return string URL to General Availability page. | |
| 238 | + */ | |
| 239 | +function wpbc_get_general_availability_url( $is_absolute_url = true, $is_old = true ) { | |
| 240 | + return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=general_availability'; | |
| 241 | +} | |
| 242 | + | |
| 243 | +/** | |
| 244 | + * Get URL of Booking > Availability > Time Slots Availability page. | |
| 245 | + * | |
| 246 | + * @param boolean $is_absolute_url Absolute or relative url { default: true }. | |
| 247 | + * @param boolean $is_old Legacy compatibility flag. | |
| 248 | + * | |
| 249 | + * @return string URL to Time Slots Availability page. | |
| 250 | + */ | |
| 251 | +function wpbc_get_time_slots_availability_url( $is_absolute_url = true, $is_old = true ) { | |
| 252 | + return wpbc_get_availability_url( $is_absolute_url, $is_old ) . '&tab=time_slots_availability'; | |
| 253 | +} | |
| 254 | + | |
| 255 | +/** | |
| 226 | 256 | * Get URL of Booking > Availability page |
| 227 | 257 | * |
| 228 | 258 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 229 | 259 | * @param boolean $is_old - { default: true } |
| @@ -239,21 +269,101 @@ | ||
| 239 | 269 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 240 | 270 | * @param boolean $is_old - { default: true } |
| 241 | 271 | * @return string - URL to menu |
| 242 | 272 | */ |
| 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 ); | |
| 273 | +function wpbc_get_new_booking_url( $is_absolute_url = true, $is_old = true ) { | |
| 274 | + return wpbc_get_menu_url( 'add', $is_absolute_url, $is_old ); | |
| 275 | +} | |
| 276 | + | |
| 277 | +/** | |
| 278 | + * Get the normalized administrator edit-booking destination. | |
| 279 | + * | |
| 280 | + * Existing installations and malformed stored values retain the popup workflow. | |
| 281 | + * The optional argument keeps normalization independently testable without | |
| 282 | + * changing a saved WordPress option. | |
| 283 | + * | |
| 284 | + * @param null|string $stored_mode Optional stored mode. Null loads the site option. | |
| 285 | + * | |
| 286 | + * @return string Either `popup` or `add_booking_page`. | |
| 287 | + */ | |
| 288 | +function wpbc_get_booking_admin_edit_mode( $stored_mode = null ) { | |
| 289 | + | |
| 290 | + if ( null === $stored_mode ) { | |
| 291 | + $stored_mode = get_bk_option( 'booking_admin_edit_booking_mode' ); | |
| 292 | + } | |
| 293 | + | |
| 294 | + $stored_mode = sanitize_key( (string) $stored_mode ); | |
| 295 | + | |
| 296 | + return in_array( $stored_mode, array( 'popup', 'add_booking_page' ), true ) ? $stored_mode : 'popup'; | |
| 297 | +} | |
| 298 | + | |
| 299 | +/** | |
| 300 | + * Check whether administrator edit links should open the dedicated Add Booking page. | |
| 301 | + * | |
| 302 | + * @param null|string $stored_mode Optional stored mode used for independent testing. | |
| 303 | + * | |
| 304 | + * @return bool True for the dedicated page; false for the default popup. | |
| 305 | + */ | |
| 306 | +function wpbc_is_booking_admin_edit_page_enabled( $stored_mode = null ) { | |
| 307 | + return 'add_booking_page' === wpbc_get_booking_admin_edit_mode( $stored_mode ); | |
| 308 | +} | |
| 309 | + | |
| 310 | +/** | |
| 311 | + * Build the authorized administrator URL for editing one Booking on Add Booking. | |
| 312 | + * | |
| 313 | + * The destination page retains its existing capability, MultiUser ownership, | |
| 314 | + * Booking hash, Resource, and Booking Form checks. This helper only centralizes | |
| 315 | + * the released URL contract used by Booking Listing and Timeline links. | |
| 316 | + * | |
| 317 | + * @param int $resource_id Booking Resource ID. | |
| 318 | + * @param string $booking_hash Booking edit hash. | |
| 319 | + * @param string $booking_form Optional custom Booking Form name. | |
| 320 | + * | |
| 321 | + * @return string Sanitized Add Booking edit URL, or an empty string when required values are missing. | |
| 322 | + */ | |
| 323 | +function wpbc_get_booking_admin_edit_url( $resource_id, $booking_hash, $booking_form = '' ) { | |
| 324 | + | |
| 325 | + $resource_id = absint( $resource_id ); | |
| 326 | + $booking_hash = sanitize_text_field( (string) $booking_hash ); | |
| 327 | + $booking_form = sanitize_text_field( (string) $booking_form ); | |
| 328 | + | |
| 329 | + if ( $resource_id < 1 || '' === $booking_hash ) { | |
| 330 | + return ''; | |
| 331 | + } | |
| 332 | + | |
| 333 | + $query_args = array( | |
| 334 | + 'booking_type' => $resource_id, | |
| 335 | + 'booking_hash' => $booking_hash, | |
| 336 | + 'parent_res' => 1, | |
| 337 | + ); | |
| 338 | + | |
| 339 | + if ( '' !== $booking_form ) { | |
| 340 | + $query_args['booking_form'] = $booking_form; | |
| 341 | + } | |
| 342 | + | |
| 343 | + return esc_url_raw( add_query_arg( $query_args, wpbc_get_new_booking_url( true, false ) ) ); | |
| 344 | +} | |
| 345 | + | |
| 346 | +/** | |
| 347 | + * Get URL of Booking > Resources page | |
| 348 | + * | |
| 349 | + * @param boolean $is_absolute_url - Absolute or relative url { default: true } | |
| 350 | + * @param boolean $is_old - { default: true } | |
| 351 | + * @return string - URL to menu | |
| 352 | + */ | |
| 353 | +function wpbc_get_resources_url( $is_absolute_url = true, $is_old = true ) { | |
| 354 | + return wpbc_get_menu_url( 'resources', $is_absolute_url, $is_old ); | |
| 245 | 355 | } |
| 246 | 356 | |
| 247 | 357 | /** |
| 248 | - * Get URL of Booking > Resources page | |
| 358 | + * Get URL of Booking > Resources > Capacity page | |
| 249 | 359 | * |
| 250 | 360 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 251 | 361 | * @param boolean $is_old - { default: true } |
| 252 | 362 | * @return string - URL to menu |
| 253 | 363 | */ |
| 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 ); | |
| 364 | +function wpbc_get_resource_capacity_url( $is_absolute_url = true, $is_old = true ) { | |
| 365 | + return wpbc_get_resources_url( $is_absolute_url, $is_old ) . '&tab=capacity'; | |
| 256 | 366 | } |
| 257 | 367 | |
| 258 | 368 | /** |
| 259 | 369 | * Get URL of Booking > Settings page |
| @@ -266,8 +376,41 @@ | ||
| 266 | 376 | return wpbc_get_menu_url( 'settings', $is_absolute_url, $is_old ); |
| 267 | 377 | } |
| 268 | 378 | |
| 269 | 379 | /** |
| 380 | + * Get URL of Booking > Settings > Calendar page | |
| 381 | + * | |
| 382 | + * @param boolean $is_absolute_url - Absolute or relative url { default: true } | |
| 383 | + * @param boolean $is_old - { default: true } | |
| 384 | + * @return string - URL to menu | |
| 385 | + */ | |
| 386 | +function wpbc_get_settings_calendar_url( $is_absolute_url = true, $is_old = true ) { | |
| 387 | + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=calendar_settings'; | |
| 388 | +} | |
| 389 | + | |
| 390 | +/** | |
| 391 | + * Get URL of Booking > Settings > Appearance / Theme page | |
| 392 | + * | |
| 393 | + * @param boolean $is_absolute_url - Absolute or relative url { default: true } | |
| 394 | + * @param boolean $is_old - { default: true } | |
| 395 | + * @return string - URL to menu | |
| 396 | + */ | |
| 397 | +function wpbc_get_settings_themes_url( $is_absolute_url = true, $is_old = true ) { | |
| 398 | + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=themes'; | |
| 399 | +} | |
| 400 | + | |
| 401 | +/** | |
| 402 | + * Get URL of Booking > Settings > Form Messages page. | |
| 403 | + * | |
| 404 | + * @param boolean $is_absolute_url Absolute or relative URL. | |
| 405 | + * @param boolean $is_old Legacy menu URL style. | |
| 406 | + * @return string | |
| 407 | + */ | |
| 408 | +function wpbc_get_settings_messages_url( $is_absolute_url = true, $is_old = true ) { | |
| 409 | + return wpbc_get_settings_url( $is_absolute_url, $is_old ) . '&tab=form_messages'; | |
| 410 | +} | |
| 411 | + | |
| 412 | +/** | |
| 270 | 413 | * Get URL of Booking > Setup page |
| 271 | 414 | * |
| 272 | 415 | * @param boolean $is_absolute_url - Absolute or relative url { default: true } |
| 273 | 416 | * @param boolean $is_old - { default: true } |
| @@ -288,8 +431,25 @@ | ||
| 288 | 431 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 289 | 432 | * |
| 290 | 433 | * @return boolean true | false |
| 291 | 434 | */ |
| 435 | +function wpbc_is_this_plugin_page( $server_param = 'REQUEST_URI' ) { | |
| 436 | + | |
| 437 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 438 | + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc' ) !== false ) ) { | |
| 439 | + return true; | |
| 440 | + } | |
| 441 | + | |
| 442 | + return false; | |
| 443 | +} | |
| 444 | + | |
| 445 | +/** | |
| 446 | + * Check if this Booking Listing or Calendar Overview page | |
| 447 | + * | |
| 448 | + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 449 | + * | |
| 450 | + * @return boolean true | false | |
| 451 | + */ | |
| 292 | 452 | function wpbc_is_bookings_page( $server_param = 'REQUEST_URI' ) { |
| 293 | 453 | // Old. |
| 294 | 454 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 295 | 455 | if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'wpdev-booking.phpwpdev-booking-reservation' ) === false ) ) { |
| @@ -311,16 +471,97 @@ | ||
| 311 | 471 | * |
| 312 | 472 | * @return boolean true | false |
| 313 | 473 | */ |
| 314 | 474 | function wpbc_is_new_booking_page( $server_param = 'REQUEST_URI' ) { |
| 315 | - // Old. | |
| 475 | + | |
| 476 | + if ( ! is_admin() || empty( $_SERVER[ $server_param ] ) ) { | |
| 477 | + return false; | |
| 478 | + } | |
| 479 | + | |
| 480 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 481 | + if ( wpbc_is_new_booking_page_url( $_SERVER[ $server_param ] ) ) { | |
| 482 | + return true; | |
| 483 | + } | |
| 484 | + | |
| 485 | + return false; | |
| 486 | +} | |
| 487 | + | |
| 488 | +/** | |
| 489 | + * Check if a URL points to Booking > Bookings > Add booking. | |
| 490 | + * | |
| 491 | + * @param string $request_uri URL or request URI. | |
| 492 | + * | |
| 493 | + * @return bool | |
| 494 | + */ | |
| 495 | +function wpbc_is_new_booking_page_url( $request_uri ) { | |
| 496 | + | |
| 497 | + $request_uri = (string) $request_uri; | |
| 498 | + | |
| 499 | + return ( | |
| 500 | + ( false !== strpos( $request_uri, 'page=wpbc' ) ) | |
| 501 | + && ( false === strpos( $request_uri, 'page=wpbc-' ) ) | |
| 502 | + && ( false !== strpos( $request_uri, 'tab=add-booking' ) ) | |
| 503 | + ); | |
| 504 | +} | |
| 505 | + | |
| 506 | +/** | |
| 507 | + * Check if this WP Booking Calendar > Settings > Booking Form page | |
| 508 | + * | |
| 509 | + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 510 | + * | |
| 511 | + * @return boolean true | false | |
| 512 | + */ | |
| 513 | +function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) { | |
| 514 | + // Regular user overwrite settings. | |
| 515 | + | |
| 516 | + // Match the legacy `form` tab exactly. A substring check also matched newer | |
| 517 | + // tabs whose names start with `form`, such as `form_messages`. | |
| 518 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 519 | + $request_uri = ! empty( $_SERVER[ $server_param ] ) ? (string) $_SERVER[ $server_param ] : ''; | |
| 520 | + $is_form_tab = (bool) preg_match( '/(?:[?&])tab=form(?:&|$)/', $request_uri ); | |
| 521 | + | |
| 522 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 523 | + $is_multiuser_form_tab = class_exists( 'wpdev_bk_multiuser' ) && ! empty( $_REQUEST['tab'] ) && 'form' === $_REQUEST['tab']; | |
| 524 | + | |
| 525 | + if ( is_admin() && false !== strpos( $request_uri, 'page=wpbc-settings' ) && ( $is_form_tab || $is_multiuser_form_tab ) ) { | |
| 526 | + return true; | |
| 527 | + } | |
| 528 | + | |
| 529 | + return false; | |
| 530 | +} | |
| 531 | + | |
| 532 | + | |
| 533 | +/** | |
| 534 | + * Check if this WP Booking Calendar > Settings > Booking Form Builder (BFB) page. | |
| 535 | + * | |
| 536 | + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 537 | + * | |
| 538 | + * @return boolean true | false | |
| 539 | + */ | |
| 540 | +function wpbc_is_settings_bfb_page( $server_param = 'REQUEST_URI' ) { | |
| 541 | + // Regular user overwrite settings. | |
| 542 | + | |
| 316 | 543 | // 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 ) ) { | |
| 544 | + 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 | 545 | return true; |
| 319 | 546 | } |
| 320 | - // New. | |
| 547 | + | |
| 548 | + return false; | |
| 549 | +} | |
| 550 | + | |
| 551 | + | |
| 552 | +/** | |
| 553 | + * Check if this WP Booking Calendar > Settings > Appearance / Theme page | |
| 554 | + * | |
| 555 | + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 556 | + * | |
| 557 | + * @return boolean true | false | |
| 558 | + */ | |
| 559 | +function wpbc_is_settings_themes_page( $server_param = 'REQUEST_URI' ) { | |
| 560 | + // Regular user overwrite settings. | |
| 561 | + | |
| 321 | 562 | // 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 ) ) { | |
| 563 | + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=themes' ) ) ) { | |
| 323 | 564 | return true; |
| 324 | 565 | } |
| 325 | 566 | |
| 326 | 567 | return false; |
| @@ -326,26 +567,57 @@ | ||
| 326 | 567 | return false; |
| 327 | 568 | } |
| 328 | 569 | |
| 329 | 570 | /** |
| 330 | - * Check if this WP Booking Calendar > Settings > Booking Form page | |
| 571 | + * Check if this WP Booking Calendar > Settings > Calendar page | |
| 331 | 572 | * |
| 332 | 573 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 333 | 574 | * |
| 334 | 575 | * @return boolean true | false |
| 335 | 576 | */ |
| 336 | -function wpbc_is_settings_form_page( $server_param = 'REQUEST_URI' ) { | |
| 577 | +function wpbc_is_settings_calendar_page( $server_param = 'REQUEST_URI' ) { | |
| 337 | 578 | // Regular user overwrite settings. |
| 338 | 579 | |
| 339 | 580 | // 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'] ) ) ) ) { | |
| 581 | + if ( ( is_admin() ) && ( false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) ) && ( false !== strpos( $_SERVER[ $server_param ], '&tab=calendar_settings' ) ) ) { | |
| 341 | 582 | return true; |
| 342 | 583 | } |
| 343 | 584 | |
| 344 | 585 | return false; |
| 345 | -} | |
| 586 | +} | |
| 587 | + | |
| 588 | +/** | |
| 589 | + * Check if this is WP Booking Calendar > Settings > Form Messages. | |
| 590 | + * | |
| 591 | + * @param string $server_param Server URL parameter. | |
| 592 | + * @return boolean | |
| 593 | + */ | |
| 594 | +function wpbc_is_settings_messages_page( $server_param = 'REQUEST_URI' ) { | |
| 595 | + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 596 | + return is_admin() && ! empty( $_SERVER[ $server_param ] ) && false !== strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) && false !== strpos( $_SERVER[ $server_param ], '&tab=form_messages' ); | |
| 597 | +} | |
| 346 | 598 | |
| 347 | 599 | /** |
| 600 | + * Check if this admin page renders a real front-end booking form or calendar preview. | |
| 601 | + * | |
| 602 | + * @return boolean true | false | |
| 603 | + */ | |
| 604 | +function wpbc_is_admin_page_with_frontend_booking_preview() { | |
| 605 | + | |
| 606 | + return ( | |
| 607 | + wpbc_is_new_booking_page() | |
| 608 | + || wpbc_is_settings_form_page() | |
| 609 | + || wpbc_is_settings_themes_page() | |
| 610 | + || wpbc_is_settings_calendar_page() | |
| 611 | + || wpbc_is_settings_messages_page() | |
| 612 | + || wpbc_is_setup_wizard_page() | |
| 613 | + || wpbc_is_builder_booking_form_page() | |
| 614 | + || ( function_exists( 'wpbc_add_appointment_page_is_active' ) && wpbc_add_appointment_page_is_active() ) | |
| 615 | + || ( function_exists( 'wpbc_is_add_booking_modal_on_booking_listing_page' ) && wpbc_is_add_booking_modal_on_booking_listing_page() ) | |
| 616 | + ); | |
| 617 | +} | |
| 618 | + | |
| 619 | +/** | |
| 348 | 620 | * Check if this Booking > Availability page |
| 349 | 621 | * |
| 350 | 622 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| 351 | 623 | * |
| @@ -361,9 +633,26 @@ | ||
| 361 | 633 | |
| 362 | 634 | return false; |
| 363 | 635 | } |
| 364 | 636 | |
| 637 | +/** | |
| 638 | + * Check if this Booking > Availability page | |
| 639 | + * | |
| 640 | + * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' | |
| 641 | + * | |
| 642 | + * @return boolean true | false | |
| 643 | + */ | |
| 644 | +function wpbc_is_builder_booking_form_page( $server_param = 'REQUEST_URI' ) { | |
| 365 | 645 | |
| 646 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | |
| 647 | + if ( ( is_admin() ) && ( strpos( $_SERVER[ $server_param ], 'page=wpbc-settings' ) !== false ) && ( strpos( $_SERVER[ $server_param ], 'tab=builder_booking_form' ) !== false ) ) { | |
| 648 | + return true; | |
| 649 | + } | |
| 650 | + | |
| 651 | + return false; | |
| 652 | +} | |
| 653 | + | |
| 654 | + | |
| 366 | 655 | /** |
| 367 | 656 | * Check if this Booking > Setup page |
| 368 | 657 | * |
| 369 | 658 | * @param string $server_param - 'REQUEST_URI' | 'HTTP_REFERER' Default: 'REQUEST_URI' |
| @@ -486,5 +775,46 @@ | ||
| 486 | 775 | $url = esc_url_raw( $url ); // FixIn: 8.1.1.7. |
| 487 | 776 | } |
| 488 | 777 | |
| 489 | 778 | return $url; |
| 490 | -} | |
| 779 | +} | |
| 780 | + | |
| 781 | + | |
| 782 | +function wpbc_left_vertival_nav__get_tab_url( $page_tag, $tab_name, $subtab_name = false, $tags = array( 'tab' => 'tab', 'subtab' => 'subtab' ) ) { | |
| 783 | + | |
| 784 | + if ( false === $subtab_name ) { | |
| 785 | + return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, ), 'admin.php' ) ) ); | |
| 786 | + } else { | |
| 787 | + return esc_url( admin_url( add_query_arg( array( 'page' => $page_tag, $tags['tab'] => $tab_name, $tags['subtab'] => $subtab_name, ), 'admin.php' ) ) ); | |
| 788 | + } | |
| 789 | +} | |
| 790 | + | |
| 791 | +/** | |
| 792 | + * Get back URL for going from edit season filter or rate to specfic main page. | |
| 793 | + * | |
| 794 | + * @return string|null | |
| 795 | + */ | |
| 796 | +function wpbc_get_back_button_url__for_seasons() { | |
| 797 | + | |
| 798 | + $page_params_arr = array( | |
| 799 | + 'page' => 'wpbc-availability', | |
| 800 | + 'page_num' => 1, | |
| 801 | + ); | |
| 802 | + | |
| 803 | + if ( ! empty( $_REQUEST['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 804 | + $page_params_arr['page'] = sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 805 | + } | |
| 806 | + if ( ! empty( $_REQUEST['tab'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 807 | + $page_params_arr['tab'] = sanitize_text_field( wp_unslash( $_REQUEST['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 808 | + } | |
| 809 | + if ( ! empty( $_REQUEST['page_num'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 810 | + $page_params_arr['page_num'] = intval( $_REQUEST['page_num'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 811 | + } | |
| 812 | + | |
| 813 | + $back_url = admin_url( | |
| 814 | + add_query_arg( | |
| 815 | + $page_params_arr, | |
| 816 | + 'admin.php' | |
| 817 | + ) | |
| 818 | + ); | |
| 819 | + return $back_url; | |
| 820 | +} | |