'wpbc', 'tab' => 'add-appointment', ), admin_url( 'admin.php' ) ); } /** * Read the page-level Appointment options from the current administrator URL. * * These values configure only the dedicated Add Appointment screen. Service * duration, buffers, price, and Booking Form remain owned by the Service. * * @return array{calendar_months:int,auto_select_provider:bool,allow_past:bool} Normalized page options. */ function wpbc_add_appointment_page_get_settings() { $months = isset( $_GET['appointment_months'] ) && ! is_array( $_GET['appointment_months'] ) ? absint( wp_unslash( $_GET['appointment_months'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended : 1; $months = min( 12, max( 1, $months ) ); return array( 'calendar_months' => $months, 'auto_select_provider' => isset( $_GET['appointment_auto_select_provider'] ) && ! is_array( $_GET['appointment_auto_select_provider'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended 'allow_past' => isset( $_GET['allow_past'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended ); } /** * Print the legacy booking context required by calendar and submit scripts. * * Reusing the Add Booking minimum-date calculation keeps past-date behavior * identical in both administrator workflows. * * @param bool $allow_past Whether past dates may be selected and submitted. * * @return void */ function wpbc_add_appointment_page_print_booking_context( $allow_past ) { $allow_past_date_arr = WPBC_Add_Booking_Component::get_allow_past_min_date_arr( array( 'allow_past' => $allow_past ? 1 : 0, 'booking_hash' => '', ) ); ?> WPBC_JS_IN_FOOTER ) ); $settings = wpbc_add_appointment_page_get_settings(); $allow_past_date_arr = WPBC_Add_Booking_Component::get_allow_past_min_date_arr( array( 'allow_past' => $settings['allow_past'] ? 1 : 0, 'booking_hash' => '', ) ); wp_localize_script( 'wpbc-add-appointment-page', 'wpbc_add_appointment_page_config', array( 'emptyLabel' => __( 'Not selected', 'booking' ), 'enabledLabel' => __( 'Enabled', 'booking' ), 'disabledLabel' => __( 'Disabled', 'booking' ), 'minutesLabel' => __( 'min', 'booking' ), 'allowPast' => $settings['allow_past'] ? 1 : 0, 'allowPastDateArr' => $allow_past_date_arr, ) ); } add_action( 'wpbc_enqueue_js_files', 'wpbc_add_appointment_page_enqueue_js', 73 ); /** * Add Appointment page integrated into the shared Booking Calendar page shell. */ class WPBC_Page_Add_Appointment extends WPBC_Page_Structure { /** * Place the page beside Booking Listing, Timeline, and Add Booking. * * @return string Parent page slug. */ public function in_page() { if ( ! WPBC_Add_Booking_Component::current_user_can_add_booking() ) { return (string) wp_rand( 100000, 1000000 ); } return 'wpbc'; } /** * Register the released Appointment tab and shared inspector layout. * * @return array> Tab definition. */ public function tabs() { return array( 'add-appointment' => array( 'is_show_top_path' => true, 'is_show_top_navigation' => true, 'left_navigation__default_view_mode' => 'min', 'right_vertical_sidebar__is_show' => true, 'right_vertical_sidebar__default_view_mode' => '', 'right_vertical_sidebar_compact__is_show' => true, 'page_title' => __( 'Add New Appointment', 'booking' ), 'page_description' => __( 'Select a Service and Provider, then create the Appointment with the existing Booking Calendar form.', 'booking' ), 'title' => __( 'Add Appointment', 'booking' ), 'hint' => __( 'Add Appointment', 'booking' ), 'font_icon' => 'wpbc-bi-plus-circle-dotted wpbc_icn_rotate_180', 'default' => false, 'disabled' => false, 'hided' => false, 'subtabs' => array(), ), ); } /** * Render compact controls for the Appointment inspector. * * @return void */ public function right_sidebar_compact_content() { WPBC_UI_Sidebar_Panels::render_rightbar_tabs( array( array( 'id' => 'wpbc_tab_add_appointment_overview', 'panel_id' => 'wpbc_add_appointment__inspector_overview', 'title' => __( 'Settings', 'booking' ), 'icon' => 'wpbc_icn_tune', 'selected' => true, ), array( 'id' => 'wpbc_tab_add_appointment_help', 'panel_id' => 'wpbc_add_appointment__inspector_help', 'title' => __( 'Help', 'booking' ), 'icon' => 'wpbc-bi-info-circle', ), ), array( 'aria_label' => __( 'Add Appointment Panels', 'booking' ), 'context' => 'add_appointment', 'class' => 'wpbc_add_appointment__rightbar_tabs', ) ); } /** * Render the standard Builder-style Appointment inspector panels. * * @return void */ public function right_sidebar_content() { ?>
'wpbc_add_appointment__inspector_overview', 'labelledby' => 'wpbc_tab_add_appointment_overview', 'class' => 'wpbc_add_appointment__inspector_overview', ), array( $this, 'render_overview_panel' ) ); WPBC_UI_Sidebar_Panels::render_panel( array( 'id' => 'wpbc_add_appointment__inspector_help', 'labelledby' => 'wpbc_tab_add_appointment_help', 'class' => 'wpbc_add_appointment__inspector_help', 'hidden' => true, ), array( $this, 'render_help_panel' ) ); ?>
'wpbc_add_appointment_summary_group', 'group' => 'add-appointment-summary', 'title' => __( 'Appointment Summary', 'booking' ), 'open' => true, ), array( $this, 'render_summary_content' ) ); WPBC_UI_Sidebar_Panels::render_collapsible_group( array( 'id' => 'wpbc_add_appointment_booking_tools_group', 'group' => 'add-appointment-booking-tools', 'title' => __( 'Booking tools', 'booking' ), 'open' => false, ), function () { $send_emails = get_bk_option( 'booking_send_emails_off_addbooking' ) !== 'On'; wpbc_render_admin_cost_correction_control( array( 'input_id' => 'wpbc_add_appointment_cost_correction', 'wrapper_class' => 'wpbc_add_appointment__setting_row wpbc_add_appointment__cost_correction', 'label_class' => 'wpbc_add_appointment__cost_correction_label', 'control_class' => 'wpbc_add_appointment__cost_correction_control', 'help_class' => 'wpbc_add_appointment__tool_help', 'help' => __( 'Leave the number empty to use the calculated Appointment cost. Enter an exact total to replace the final cost for this Appointment.', 'booking' ), ) ); ?>
'is_send_email_for_pending', 'name' => 'is_send_email_for_pending', 'label' => array( 'title' => __( 'Emails sending', 'booking' ) ), 'value' => 'On', 'selected' => $send_emails, 'legend' => __( 'Send email notifications for this Appointment', 'booking' ), ) ); ?>

'wpbc_add_appointment_booking_options_group', 'group' => 'add-appointment-booking-options', 'title' => __( 'Booking options', 'booking' ), 'open' => false, ), function () use ( $settings ) { ?>

'wpbc_add_appointment__auto_provider', 'name' => 'appointment_auto_select_provider', 'label' => array( 'title' => __( 'Auto-select the only Provider', 'booking' ) ), 'value' => '1', 'selected' => $settings['auto_select_provider'], 'legend' => __( 'Auto-select the only compatible Provider', 'booking' ), ) ); ?>

'wpbc_add_appointment__allow_past', 'name' => 'allow_past', 'label' => array( 'title' => __( 'Allow booking in the past', 'booking' ) ), 'value' => '1', 'selected' => $settings['allow_past'], 'legend' => __( 'Allow booking in the past', 'booking' ), ) ); ?>

'wpbc_add_appointment_manage_setup_group', 'group' => 'add-appointment-manage-setup', 'title' => __( 'Manage setup', 'booking' ), 'open' => false, ), function () { ?>

—
—
—
—
—
—
—
—
—
—

  1. 1
  2. 2
  3. 3

$settings['calendar_months'], 'auto_select_provider' => $settings['auto_select_provider'], 'allow_past' => $settings['allow_past'], ); $config = (array) apply_filters( 'wpbc_admin_add_appointment_config', $config, $settings ); wpbc_add_appointment_page_print_booking_context( $settings['allow_past'] ); ?>