| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Add Booking modal for Booking Listing and Timeline. |
| 4 | 4 | * |
| @@ -86,12 +86,13 @@ | ||
| 86 | 86 | <div id="wpbc_modal__add_booking__body" class="wpbc_modal__add_booking__body"> |
| 87 | 87 | <?php self::print_loading_spinner(); ?> |
| 88 | 88 | </div> |
| 89 | 89 | </div> |
| 90 | - <div class="modal-footer"> | |
| 91 | - <div class="wpbc_modal__add_booking__footer_time_override" data-wpbc-add-booking-time-override-footer="1"></div> | |
| 92 | - <?php self::print_modal_send_emails_toggle(); ?> | |
| 93 | - <a href="javascript:void(0)" id="wpbc_modal__add_booking__button_send" class="button button-primary" onclick="wpbc_boo_listing__submit__add_booking_modal();"> | |
| 90 | + <div class="modal-footer"> | |
| 91 | + <div class="wpbc_modal__add_booking__footer_time_override" data-wpbc-add-booking-time-override-footer="1"></div> | |
| 92 | + <?php self::print_modal_send_emails_toggle(); ?> | |
| 93 | + <?php self::print_add_appointment_entry(); ?> | |
| 94 | + <a href="javascript:void(0)" id="wpbc_modal__add_booking__button_send" class="button button-primary" onclick="wpbc_boo_listing__submit__add_booking_modal();"> | |
| 94 | 95 | <?php esc_html_e( 'Add booking', 'booking' ); ?> |
| 95 | 96 | </a> |
| 96 | 97 | <a href="javascript:void(0)" class="button button-secondary" data-dismiss="modal"> |
| 97 | 98 | <?php esc_html_e( 'Close', 'booking' ); ?> |
| @@ -101,9 +102,37 @@ | ||
| 101 | 102 | </div><!-- /.modal-dialog --> |
| 102 | 103 | </div><!-- /.modal --> |
| 103 | 104 | </span> |
| 104 | 105 | <?php |
| 105 | - } | |
| 106 | + } | |
| 107 | + | |
| 108 | + | |
| 109 | + /** | |
| 110 | + * Print the released route to the Service-first administrator workflow. | |
| 111 | + * | |
| 112 | + * The standard Add Booking form remains the popup's primary action. This | |
| 113 | + * secondary route is hidden by the modal client whenever an existing booking | |
| 114 | + * is being edited. | |
| 115 | + * | |
| 116 | + * @return void | |
| 117 | + */ | |
| 118 | + private static function print_add_appointment_entry() { | |
| 119 | + if ( | |
| 120 | + ! function_exists( 'wpbc_add_appointment_page_get_url' ) | |
| 121 | + || ! WPBC_Add_Booking_Component::current_user_can_add_booking() | |
| 122 | + ) { | |
| 123 | + return; | |
| 124 | + } | |
| 125 | + ?> | |
| 126 | + <a href="<?php echo esc_url( wpbc_add_appointment_page_get_url() ); ?>" | |
| 127 | + class="button button-secondary wpbc_modal__add_booking__appointment_entry" | |
| 128 | + data-wpbc-add-appointment-entry="1" | |
| 129 | + title="<?php esc_attr_e( 'Choose a Service and Provider before creating the booking', 'booking' ); ?>"> | |
| 130 | + <i class="menu_icon icon-1x wpbc-bi-calendar-plus" aria-hidden="true"></i> | |
| 131 | + <?php esc_html_e( 'Add Appointment', 'booking' ); ?> | |
| 132 | + </a> | |
| 133 | + <?php | |
| 134 | + } | |
| 106 | 135 | |
| 107 | 136 | |
| 108 | 137 | /** |
| 109 | 138 | * Print modal-scoped email notification toggle. |
| @@ -250,9 +279,9 @@ | ||
| 250 | 279 | * @return void |
| 251 | 280 | */ |
| 252 | 281 | private static function print_modal_booking_form_edit_link() { |
| 253 | 282 | |
| 254 | - if ( ! defined( 'WPBC_NEW_FORM_BUILDER' ) || ! WPBC_NEW_FORM_BUILDER || ! function_exists( 'wpbc_get_settings_url' ) ) { | |
| 283 | + if ( ! function_exists( 'wpbc_get_settings_url' ) ) { | |
| 255 | 284 | return; |
| 256 | 285 | } |
| 257 | 286 | |
| 258 | 287 | $base_url = add_query_arg( |
| @@ -354,8 +383,13 @@ | ||
| 354 | 383 | ) { |
| 355 | 384 | wp_send_json_error( array( 'message' => __( 'You do not have access to this booking resource.', 'booking' ) ), 403 ); |
| 356 | 385 | } |
| 357 | 386 | |
| 387 | + if ( ( 'add' === $args['mode'] ) && ( '' === (string) $args['booking_form'] ) ) { | |
| 388 | + $args['booking_form'] = WPBC_Add_Booking_Component::get_default_booking_form_for_resource( $args['resource_id'], 'standard' ); | |
| 389 | + $args['custom_booking_form'] = $args['booking_form']; | |
| 390 | + } | |
| 391 | + | |
| 358 | 392 | $html = self::render_component_with_legacy_request_context( $args ); |
| 359 | 393 | |
| 360 | 394 | wp_send_json_success( |
| 361 | 395 | array( |
| @@ -368,8 +402,9 @@ | ||
| 368 | 402 | 'booking_id' => absint( $args['booking_id'] ), |
| 369 | 403 | 'booking_form' => (string) $args['booking_form'], |
| 370 | 404 | 'allow_past' => absint( $args['allow_past'] ), |
| 371 | 405 | 'selected_dates_without_calendar' => (string) $args['selected_dates_without_calendar'], |
| 406 | + 'selected_dates' => (string) $args['selected_dates'], | |
| 372 | 407 | 'selected_date' => (string) $args['selected_date'], |
| 373 | 408 | 'selected_time' => (string) $args['selected_time'], |
| 374 | 409 | 'time_override_enabled' => absint( $args['time_override_enabled'] ), |
| 375 | 410 | 'time_override_source' => (string) $args['time_override_source'], |
| @@ -395,8 +430,9 @@ | ||
| 395 | 430 | $booking_id = isset( $_POST['booking_id'] ) ? absint( $_POST['booking_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 396 | 431 | $booking_form = isset( $_POST['booking_form'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_form'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 397 | 432 | $allow_past = isset( $_POST['allow_past'] ) ? absint( $_POST['allow_past'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 398 | 433 | $selected_dates_without_calendar = isset( $_POST['selected_dates_without_calendar'] ) ? sanitize_text_field( wp_unslash( $_POST['selected_dates_without_calendar'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 434 | + $selected_dates = isset( $_POST['selected_dates'] ) ? sanitize_text_field( wp_unslash( $_POST['selected_dates'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 399 | 435 | $selected_date = isset( $_POST['selected_date'] ) ? sanitize_text_field( wp_unslash( $_POST['selected_date'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 400 | 436 | $selected_time = isset( $_POST['selected_time'] ) ? sanitize_text_field( wp_unslash( $_POST['selected_time'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 401 | 437 | $time_override_enabled = isset( $_POST['time_override_enabled'] ) ? absint( $_POST['time_override_enabled'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| 402 | 438 | $time_override_source = isset( $_POST['time_override_source'] ) ? sanitize_key( wp_unslash( $_POST['time_override_source'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing |
| @@ -424,8 +460,9 @@ | ||
| 424 | 460 | 'booking_form' => $booking_form, |
| 425 | 461 | 'custom_booking_form' => $booking_form, |
| 426 | 462 | 'allow_past' => $allow_past ? 1 : 0, |
| 427 | 463 | 'selected_dates_without_calendar' => $selected_dates_without_calendar, |
| 464 | + 'selected_dates' => $selected_dates, | |
| 428 | 465 | 'selected_date' => $selected_date, |
| 429 | 466 | 'selected_time' => $selected_time, |
| 430 | 467 | 'time_override_enabled' => ( $time_override_enabled && $time_override_start && $time_override_end ) ? 1 : 0, |
| 431 | 468 | 'time_override_source' => $time_override_source, |
| @@ -597,8 +634,14 @@ | ||
| 597 | 634 | public static function is_supported_admin_page() { |
| 598 | 635 | |
| 599 | 636 | if ( ! is_admin() ) { |
| 600 | 637 | return false; |
| 638 | + } | |
| 639 | + | |
| 640 | + if ( function_exists( 'wpbc_is_availability_page' ) && wpbc_is_availability_page() ) { | |
| 641 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing | |
| 642 | + $requested_tab = isset( $_REQUEST['tab'] ) ? sanitize_key( wp_unslash( $_REQUEST['tab'] ) ) : ''; | |
| 643 | + return ( 'time_slots_availability' === $requested_tab ); | |
| 601 | 644 | } |
| 602 | 645 | |
| 603 | 646 | if ( function_exists( 'wpbc_is_bookings_page' ) ) { |
| 604 | 647 | if ( ! wpbc_is_bookings_page() ) { |