'none', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''. 'title' => __( 'Setup', 'booking' ) // Title of TAB , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint , 'page_title' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link , 'position' => '' // 'left' || 'right' || '' , 'css_classes' => '' // CSS class(es) , 'icon' => '' // Icon - link to the real PNG img , 'font_icon' => 'wpbc_icn_donut_large' //'wpbc_icn_free_cancellation' // CSS definition of forn Icon , 'default' => true // Is this tab activated by default or not: true || false. , 'disabled' => false // Is this tab disbaled: true || false. , 'hided' => false // Is this tab hided: true || false. , 'subtabs' => array() ); $subtabs = array(); $subtabs['path_setup'] = array( 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html' , 'title' => __( 'Setup', 'booking' ) // Title of TAB , 'page_title'=> false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint , 'link' => '#path_setup' // link , 'position' => '' // 'left' || 'right' || '' , 'css_classes' => '' // CSS class(es) //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon , 'default' => true // Is this sub tab activated by default or not: true || false. , 'disabled' => false // Is this sub tab deactivated: true || false. , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' ) , 'content' => 'content' // Function to load as content of this TAB , 'is_use_navigation_path' => array( 'path' => array( 'go_back_to_dashboard' => array( 'title' => __('Go to Dashboard','booking'), 'hint' => __('Go back to the Dashboard','booking'), 'icon' => 'wpbc_icn_navigate_before', 'url' => wpbc_get_bookings_url(), //wpbc_get_settings_url(), 'attr' => array( 'style' => 'border-right: 1px solid #0000001a; margin-right: 10px;padding-right: 25px;' . ( !$this->is_full_screen ? 'display:none;' : '' ) ), 'class' => 'wpbc_full_screen_mode_buttons' ), // 'go_back_separtor' => array( 'tag' => '|' ), //array( 'tag' => '>' ), 'setup' => array( 'title' => __('Setup','booking'), 'hint' => __('Initial Setup','booking'), 'icon' => 'wpbc_icn_donut_large wpbc_spin wpbc_animation_pause', // -> wpbc_setup_wizard_page_reload_button__spin_start( ... ) 'attr' => array( 'style' => 'pointer-events: none;', 'id' => 'wpbc_initial_setup_top_menu_item' ), 'url' => '', 'tag' => 'div', 'class' => 'nav-tab-active' ), // 'next_all' => array( 'tag' => '>' ), // 'intro' => array( // 'title' => __('Step','booking') . ' ' . wpbc_setup_wizard_page__get_active_step() . ' / ' .wpbc_setup_wizard_page__get_total_steps(), // 'hint' => __('General Settings','booking'), // 'icon' => 'wpbc_icn_layers outlined_flag',//'wpbc_icn_adjust', // 'url' => wpbc_get_setup_wizard_page_url() . '&tab=step_01', // //'attr' => array() // //'tag' => 'a', // 'class' => 'nav-tab-active' // ), 'wpbc__container_place__steps_for_timeline' => array( 'title' => '', 'hint' => '', 'icon' => '', 'action' => '', 'attr' => array( 'style' => '' ), 'tag' => 'div', 'class' => 'wpbc__container_place__steps_for_timeline' ), 'full_screen' => array( 'title' => '',//__('Full Screen','booking'), 'hint' => __('Full Screen','booking'), 'icon' => 'wpbc-bi-arrows-fullscreen 0wpbc_icn_zoom_out_map 0wpbc_icn_open_in_full', 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();", 'attr' => array( 'style' => 'margin-left:auto;' . ( $this->is_full_screen ? 'display:none;' : '' ) ), //'tag' => 'a', 'class' => 'wpbc_full_screen_mode_buttons' ), 'full_screen_exit' => array( 'title' => '', 'hint' => __('Exit Full Screen','booking'), 'icon' => 'wpbc-bi-arrows-angle-contract 0wpbc_icn_zoom_in_map 0wpbc_icn_close_fullscreen', 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();", 'attr' => array( 'style' => 'margin-left:auto;' . ( !$this->is_full_screen ? 'display:none;' : '' ) ), //'tag' => 'a', 'class' => 'wpbc_full_screen_mode_buttons' ) ) ) ); $tabs[ 'step_01' ][ 'subtabs' ] = $subtabs; return $tabs; } public function content() { do_action( 'wpbc_hook_settings_page_header', 'page_booking_setup_wizard'); // Define Notices Section and show some static messages, if needed. // ------------------------------------------------------------------------------------------------------------- // Check MultiUser params // ------------------------------------------------------------------------------------------------------------- if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message. // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user. // ------------------------------------------------------------------------------------------------------------- // Get and escape request parameters // ------------------------------------------------------------------------------------------------------------- $escaped_request_params_arr = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default(); // ------------------------------------------------------------------------------------------------------------- // Main Submit Form (if needed ?) // ------------------------------------------------------------------------------------------------------------- $submit_form_name = 'wpbc_setup_wizard_page_form'; // Define form name ?>
show__main_container( $escaped_request_params_arr ); //wpbc_show_wpbc_footer(); // Rating do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_setup_wizard' ); } private function show__main_container( $escaped_request_params_arr ) { wpbc_clear_div(); ?> is_full_screen ) ) { $classes .= ' wpbc_admin_full_screen'; } return $classes; } } add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Setup_Wizard() , '__construct') ); // Executed after creation of Menu /** * Make Setup Status Reset or Complete from URL * * @return bool */ function wpbc_setup_wizard_page__force_in_get() { // Se it as DONE // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'completed' === $_REQUEST['wpbc_setup_wizard'] ) { $setup_steps = new WPBC_SETUP_WIZARD_STEPS(); $setup_steps->db__set_all_steps_as( true ); wpbc_setup_wizard__set_full_screen_mode_for_current_user( false ); return true; } // Reset // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'reset' === $_REQUEST['wpbc_setup_wizard'] ) { // ------------------------------------------------------------------------------------------------------------- // == Request == -> $_REQUEST['all_ajx_params']['page_num'], $_REQUEST['all_ajx_params']['page_items_count'], ... // ------------------------------------------------------------------------------------------------------------- $user_request = new WPBC_AJX__REQUEST( array( 'db_option_name' => 'booking_setup_wizard_page_request_params', 'user_id' => wpbc_get_current_user_id(), 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure() ) ); // Delete from DB $is_reseted = $user_request->user_request_params__db_delete(); // Clear All Steps Mark as Undone $setup_steps = new WPBC_SETUP_WIZARD_STEPS(); $setup_steps->db__set_all_steps_as( false ); update_bk_option( 'booking_wizard_data', array() ); wpbc_setup_wizard__set_full_screen_mode_for_current_user( false ); return true; } $setup_steps = new WPBC_SETUP_WIZARD_STEPS(); $steps_arr = $setup_steps->get_steps_arr(); $request_step = ''; if ( 'On' === get_bk_option( 'booking_setup_wizard_page_is_completed' ) ) { wpbc_setup_wizard__set_full_screen_mode_for_current_user( false ); return true; } $is_external_setup_flow_started = $setup_steps->db__is_step_completed( 'bookings_types' ); // Persist the real setup step when the user lands on an external WPBC admin page. // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $request_step_from_request = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) ); if ( isset( $steps_arr[ $request_step_from_request ] ) ) { $request_step = $request_step_from_request; $setup_steps->db__save_current_step_name( $request_step ); wpbc_setup_wizard__set_full_screen_mode_for_current_user( ( ! wpbc_setup_wizard__is_internal_step( $request_step ) ) && ( 'get_started' !== $request_step ) ); } } if ( $is_external_setup_flow_started && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_request' ) ) { $detected_step = wpbc_setup_wizard__detect_step_from_admin_request(); if ( empty( $request_step ) && ! empty( $detected_step ) && isset( $steps_arr[ $detected_step ] ) ) { $setup_steps->db__save_current_step_name( $detected_step ); wpbc_setup_wizard__set_full_screen_mode_for_current_user( ! wpbc_setup_wizard__is_internal_step( $detected_step ) ); } } // Existing settings pages submit their own forms. This flag lets the setup bar remember that save across reloads. // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_saved_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $saved_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_saved_step'] ) ); if ( isset( $steps_arr[ $saved_step ] ) ) { $setup_steps->db__set_step_as_saved( $saved_step, true ); $setup_steps->db__save_current_step_name( $saved_step ); } } // Continue from an existing WPBC settings page to the next setup target. // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'continue' === $_REQUEST['wpbc_setup_wizard'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; if ( ! wp_verify_nonce( $nonce, 'wpbc_settings_url_nonce' ) ) { return false; } $setup_steps = new WPBC_SETUP_WIZARD_STEPS(); $steps_arr = $setup_steps->get_steps_arr(); $current_step = $setup_steps->get_saved_current_step_name(); $has_explicit_step_context = false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $request_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) ); if ( isset( $steps_arr[ $request_step ] ) ) { $current_step = $request_step; $has_explicit_step_context = true; } } // Prefer the step detected on the page that rendered the setup bar. This avoids stale saved state taking over. // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['wpbc_setup_from_page_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $from_page_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_from_page_step'] ) ); if ( isset( $steps_arr[ $from_page_step ] ) ) { $current_step = $from_page_step; $has_explicit_step_context = true; if ( 'form_structure' === $current_step ) { $setup_steps->db__set_step_as_saved( $current_step, true ); } } } if ( ( ! $has_explicit_step_context ) && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_url' ) ) { $referer_step = wpbc_setup_wizard__detect_step_from_admin_url( wp_get_referer() ); if ( ! empty( $referer_step ) && isset( $steps_arr[ $referer_step ] ) ) { $current_step = $referer_step; if ( 'form_structure' === $current_step ) { $setup_steps->db__set_step_as_saved( $current_step, true ); } } } $setup_steps->db__save_current_step_name( $current_step ); if ( isset( $steps_arr[ $current_step ] ) && 'manual_save_required' === $setup_steps->get_step_save_behavior( $current_step ) && ! $setup_steps->db__is_step_saved( $current_step ) ) { wpbc_redirect( add_query_arg( 'wpbc_setup_save_required', '1', $setup_steps->get_step_target_url( $current_step ) ) ); exit; } if ( isset( $steps_arr[ $current_step ] ) ) { $setup_steps->db__set_step_as_completed( $current_step ); } $next_step = isset( $steps_arr[ $current_step ]['next'] ) ? $steps_arr[ $current_step ]['next'] : ''; if ( ( empty( $next_step ) || ( 'welcome' === $next_step ) ) && function_exists( 'wpbc_setup_wizard__get_next_step_name' ) ) { $route_next_step = wpbc_setup_wizard__get_next_step_name( $current_step ); if ( ! empty( $route_next_step ) && isset( $steps_arr[ $route_next_step ] ) ) { $next_step = $route_next_step; } } if ( empty( $next_step ) || ( 'welcome' === $next_step ) ) { if ( 'get_started' === $current_step || 'complete' === $setup_steps->get_step_save_behavior( $current_step ) ) { $setup_steps->db__set_all_steps_as( true ); wpbc_setup_wizard__set_full_screen_mode_for_current_user( false ); wpbc_redirect( wpbc_get_bookings_url() ); exit; } if ( 'get_started' !== $current_step ) { $fallback_step = $setup_steps->get_active_step_name(); if ( ( ! empty( $fallback_step ) ) && isset( $steps_arr[ $fallback_step ] ) && ( $fallback_step !== $current_step ) && ! $setup_steps->db__is_step_completed( $fallback_step ) ) { $setup_steps->db__save_current_step_name( $fallback_step ); wpbc_redirect( $setup_steps->get_step_target_url( $fallback_step ) ); exit; } } wpbc_setup_wizard__set_full_screen_mode_for_current_user( false ); wpbc_redirect( wpbc_get_bookings_url() ); exit; } $setup_steps->db__reset_steps_from( $next_step ); $request_params_to_save = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default(); if ( ! is_array( $request_params_to_save ) ) { $request_params_to_save = wpbc_setup_wizard_page__get__request_values__default(); } $request_params_to_save['current_step'] = $next_step; if ( isset( $steps_arr[ $next_step ] ) && 'manual_save_required' === $setup_steps->get_step_save_behavior( $next_step ) && ! $setup_steps->db__is_step_completed( $next_step ) ) { $setup_steps->db__set_step_as_saved( $next_step, false ); } $user_request = new WPBC_AJX__REQUEST( array( 'db_option_name' => 'booking_setup_wizard_page_request_params', 'user_id' => wpbc_get_current_user_id(), 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure() ) ); $user_request->user_request_params__db_save( $request_params_to_save ); wpbc_redirect( $setup_steps->get_step_target_url( $next_step ) ); exit; } // In the guided setup architecture, Step 5+ is configured on existing WPBC admin pages. if ( wpbc_is_setup_wizard_page() && ( ! ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) ) ) { $current_step = $setup_steps->get_saved_current_step_name(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing if ( isset( $_REQUEST['current_step'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing $request_step = sanitize_key( wp_unslash( $_REQUEST['current_step'] ) ); if ( isset( $steps_arr[ $request_step ] ) ) { $current_step = $request_step; } } if ( isset( $steps_arr[ $current_step ]['is_external'] ) && $steps_arr[ $current_step ]['is_external'] ) { wpbc_redirect( $setup_steps->get_step_target_url( $current_step ) ); exit; } } return false; } add_action( 'init', 'wpbc_setup_wizard_page__force_in_get' );