PluginProbe
Booking Calendar / 11.8
Booking Calendar v11.8
11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 10.11.2 10.11.3 10.11.4 All 201 releases
booking / includes / page-setup / setup__page.php

setup__page.php in Booking Calendar 11.8, at includes/page-setup/setup__page.php

533 lines 26.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * @package: AJX_Setup_Wizard Page
4 * @category: Initial setup and plugin customization
5 * Author: wpdevelop, oplugins
6 * Version: 1.0
7 * @modified 2024-06-28
8 */
9 // FixIn: 10.2.0.1.
10 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
11
12 /**
13 * The setup wizard renders only the introductory steps on this page. Profile-specific configuration after
14 * "Booking Type" is routed to existing WPBC admin pages and controlled by the floating setup bar.
15 */
16
17
18 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_templates.php' );
19 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_profiles.php' );
20 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/01.welcome__tpl.php' );
21
22 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/02.general_info__tpl.php' );
23 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/02.general_info__action.php' );
24
25 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/03.date_time_formats__tpl.php' );
26 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/03.date_time_formats__action.php' );
27
28 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/04.bookings_types__tpl.php' );
29 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/templates/04.bookings_types__action.php' );
30
31 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_steps.php' );
32 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_ajax.php' );
33 require_once( WPBC_PLUGIN_DIR . '/includes/page-setup/setup_support.php' );
34
35 /** Show Content
36 * Update Content
37 * Define Slug
38 * Define where to show
39 */
40 class WPBC_Page_AJX_Setup_Wizard extends WPBC_Page_Structure {
41
42 private $is_full_screen = true;
43
44 public function __construct() {
45
46 parent::__construct();
47
48 add_filter( 'admin_body_class', array( $this, 'add_loading_classes' ) );
49 }
50
51
52 public function in_page() {
53 return 'wpbc-setup';
54 }
55
56
57 public function tabs() {
58
59 $tabs = array();
60 $tabs[ 'step_01' ] = array(
61 'is_force_full_screen' => true, // true | false. Force full screen independently from user preference.
62 'left_navigation__default_view_mode' => 'none', // '' | 'min' | 'compact' | 'max' | 'none'. By default value is: ''.
63 'left_navigation__force_view_mode' => 'none', // '' | 'min' | 'compact' | 'max' | 'none'. Force sidebar mode independently from user preference.
64 'title' => __( 'Setup', 'booking' ) // Title of TAB
65 , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
66 , 'page_title' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
67 , 'link' => '' // Can be skiped, then generated link based on Page and Tab tags. Or can be extenral link
68 , 'position' => '' // 'left' || 'right' || ''
69 , 'css_classes' => '' // CSS class(es)
70 , 'icon' => '' // Icon - link to the real PNG img
71 , 'font_icon' => 'wpbc_icn_donut_large' //'wpbc_icn_free_cancellation' // CSS definition of forn Icon
72 , 'default' => true // Is this tab activated by default or not: true || false.
73 , 'disabled' => false // Is this tab disbaled: true || false.
74 , 'hided' => false // Is this tab hided: true || false.
75 , 'subtabs' => array()
76 );
77
78 $subtabs = array();
79 $subtabs['path_setup'] = array(
80 'type' => 'subtab' // Required| Possible values: 'subtab' | 'separator' | 'button' | 'goto-link' | 'html'
81 , 'title' => __( 'Setup', 'booking' ) // Title of TAB
82 , 'page_title'=> false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Title of Page
83 , 'hint' => false//__( 'Setup', 'booking' ) . ' - ' . 'Booking Calendar' // Hint
84 , 'link' => '#path_setup' // link
85 , 'position' => '' // 'left' || 'right' || ''
86 , 'css_classes' => '' // CSS class(es)
87 //, 'icon' => 'http://.../icon.png' // Icon - link to the real PNG img
88 //, 'font_icon' => 'wpbc_icn_mail_outline' // CSS definition of Font Icon
89 , 'default' => true // Is this sub tab activated by default or not: true || false.
90 , 'disabled' => false // Is this sub tab deactivated: true || false.
91 , 'checkbox' => false // or definition array for specific checkbox: array( 'checked' => true, 'name' => 'feature1_active_status' ) //, 'checkbox' => array( 'checked' => $is_checked, 'name' => 'enabled_active_status' )
92 , 'content' => 'content' // Function to load as content of this TAB
93 , 'is_use_navigation_path' => array(
94 'path' => array(
95 'go_back_to_dashboard' => array(
96 'title' => __('Go to Dashboard','booking'),
97 'hint' => __('Go back to the Dashboard','booking'),
98 'icon' => 'wpbc_icn_navigate_before',
99 'url' => wpbc_get_bookings_url(), //wpbc_get_settings_url(),
100 'attr' => array( 'style' => 'border-right: 1px solid #0000001a; margin-right: 10px;padding-right: 25px;' .
101 ( !$this->is_full_screen ? 'display:none;' : '' ) ),
102 'class' => 'wpbc_full_screen_mode_buttons'
103 ),
104 // 'go_back_separtor' => array( 'tag' => '|' ), //array( 'tag' => '>' ),
105 'setup' => array(
106 'title' => __('Setup','booking'),
107 'hint' => __('Initial Setup','booking'),
108 'icon' => 'wpbc_icn_donut_large wpbc_spin wpbc_animation_pause', // -> wpbc_setup_wizard_page_reload_button__spin_start( ... )
109 'attr' => array( 'style' => 'pointer-events: none;', 'id' => 'wpbc_initial_setup_top_menu_item' ),
110 'url' => '',
111 'tag' => 'div',
112 'class' => 'nav-tab-active'
113 ),
114 // 'next_all' => array( 'tag' => '>' ),
115 // 'intro' => array(
116 // 'title' => __('Step','booking') . ' ' . wpbc_setup_wizard_page__get_active_step() . ' / ' .wpbc_setup_wizard_page__get_total_steps(),
117 // 'hint' => __('General Settings','booking'),
118 // 'icon' => 'wpbc_icn_layers outlined_flag',//'wpbc_icn_adjust',
119 // 'url' => wpbc_get_setup_wizard_page_url() . '&tab=step_01',
120 // //'attr' => array()
121 // //'tag' => 'a',
122 // 'class' => 'nav-tab-active'
123 // ),
124 'wpbc__container_place__steps_for_timeline' => array(
125 'title' => '',
126 'hint' => '',
127 'icon' => '',
128 'action' => '',
129 'attr' => array( 'style' => '' ),
130 'tag' => 'div',
131 'class' => 'wpbc__container_place__steps_for_timeline'
132 ),
133 'full_screen' => array(
134 'title' => '',//__('Full Screen','booking'),
135 'hint' => __('Full Screen','booking'),
136 'icon' => 'wpbc-bi-arrows-fullscreen 0wpbc_icn_zoom_out_map 0wpbc_icn_open_in_full',
137 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
138 'attr' => array( 'style' => 'margin-left:auto;' . ( $this->is_full_screen ? 'display:none;' : '' ) ),
139 //'tag' => 'a',
140 'class' => 'wpbc_full_screen_mode_buttons'
141 ),
142 'full_screen_exit' => array(
143 'title' => '',
144 'hint' => __('Exit Full Screen','booking'),
145 'icon' => 'wpbc-bi-arrows-angle-contract 0wpbc_icn_zoom_in_map 0wpbc_icn_close_fullscreen',
146 'action' => "jQuery('body').toggleClass('wpbc_admin_full_screen');wpbc_check_full_screen_mode();jQuery('.wpbc_full_screen_mode_buttons').toggle();",
147 'attr' => array( 'style' => 'margin-left:auto;' . ( !$this->is_full_screen ? 'display:none;' : '' ) ),
148 //'tag' => 'a',
149 'class' => 'wpbc_full_screen_mode_buttons'
150 )
151 )
152 )
153 );
154 $tabs[ 'step_01' ][ 'subtabs' ] = $subtabs;
155
156 return $tabs;
157 }
158
159
160 public function content() {
161
162 do_action( 'wpbc_hook_settings_page_header', 'page_booking_setup_wizard'); // Define Notices Section and show some static messages, if needed.
163
164 // -------------------------------------------------------------------------------------------------------------
165 // Check MultiUser params
166 // -------------------------------------------------------------------------------------------------------------
167 if ( ! wpbc_is_mu_user_can_be_here( 'activated_user' ) ) { return false; } // Check if MU user activated, otherwise show Warning message.
168 // if ( ! wpbc_set_default_resource_to__get() ) return false; // Define default booking resources for $_GET and check if booking resource belong to user.
169
170
171 // -------------------------------------------------------------------------------------------------------------
172 // Get and escape request parameters
173 // -------------------------------------------------------------------------------------------------------------
174 $escaped_request_params_arr = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();
175
176
177 // -------------------------------------------------------------------------------------------------------------
178 // Main Submit Form (if needed ?)
179 // -------------------------------------------------------------------------------------------------------------
180 $submit_form_name = 'wpbc_setup_wizard_page_form'; // Define form name
181 ?><form name="<?php echo esc_attr( $submit_form_name ); ?>" id="<?php echo esc_attr( $submit_form_name ); ?>" action="" method="post" >
182 <?php
183 // N o n c e field, and key for checking S u b m i t
184 wp_nonce_field( 'wpbc_settings_page_' . $submit_form_name );
185 ?><input type="hidden" name="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" id="is_form_sbmitted_<?php echo esc_attr( $submit_form_name ); ?>" value="1" /><?php
186
187 ?></form><?php
188
189 // -------------------------------------------------------------------------------------------------------------
190 // JS :: Tooltips, Popover, Datepicker
191 // -------------------------------------------------------------------------------------------------------------
192 wpbc_js_for_bookings_page();
193
194 ?><div id="wpbc_log_screen" class="wpbc_log_screen"></div><?php
195
196 ?><div class="wpbc_page_publish_notice_section"><?php
197 // This is required for submit of Embed shortcodes into New or Existing pages !
198 do_action( 'wpbc_hook_settings_page_before_content_table', 'resources' ); // Define Notices Section and show some static messages, if needed
199 ?></div><?php
200 // -------------------------------------------------------------------------------------------------------------
201 // == Content ==
202 // -------------------------------------------------------------------------------------------------------------
203 $this->show__main_container( $escaped_request_params_arr );
204
205 //wpbc_show_wpbc_footer(); // Rating
206
207 do_action( 'wpbc_hook_settings_page_footer', 'wpbc-ajx_booking_setup_wizard' );
208 }
209
210
211 private function show__main_container( $escaped_request_params_arr ) {
212
213 wpbc_clear_div();
214 ?>
215 <span class="metabox-holder">
216 <div id="ajx_nonce_calendar_section"></div>
217 <div class="wpbc_setup_wizard_page_container" wpbc_loaded="first_time">
218 <div class="wpbc_calendar_loading"><span class="wpbc_icn_autorenew wpbc_spin"></span>&nbsp;&nbsp;<span><?php esc_html_e( 'Loading', 'booking' ); ?>...</span></div>
219 </div>
220 </span>
221 <?php
222
223 wpbc_clear_div();
224
225 ?><script type="text/javascript"><?php
226 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
227 echo wpbc_jq_ready_start();
228 if( $this->is_full_screen ) {
229 ?>
230 jQuery( '.wpbc_ui__top_nav__btn_full_screen,.wpbc_ui__top_nav__btn_normal_screen' ).toggleClass( 'wpbc_ui__hide' );
231 wpbc_check_full_screen_mode();
232 <?php
233 }
234 ?>
235
236 // Set Security - Nonce for Ajax - Listing
237 _wpbc_settings.set_param__secure( 'nonce', '<?php echo esc_js( wp_create_nonce( 'wpbc_setup_wizard_page_ajx' . '_wpbcnonce' ) ); ?>' );
238 _wpbc_settings.set_param__secure( 'user_id', '<?php echo esc_js( wpbc_get_current_user_id() ); ?>' );
239 _wpbc_settings.set_param__secure( 'locale', '<?php echo esc_js( get_user_locale() ); ?>' );
240
241 // Set other parameters
242 _wpbc_settings.set_param__other( 'container__main_content', '.wpbc_setup_wizard_page_container' );
243
244 // Send Ajax and then show content
245 wpbc_ajx__setup_wizard_page__send_request_with_params( <?php echo wp_json_encode( $escaped_request_params_arr ); ?> );
246 <?php
247 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
248 echo wpbc_jq_ready_end();
249 ?></script><?php
250
251 /**
252 * JS Examples of showing specific Step:
253 * wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step':'date_availability' } );
254 *
255 * wpbc_ajx__setup_wizard_page__send_request_with_params( { 'current_step':'general_info' } );
256 */
257 }
258
259
260 /**
261 * Set the admin full screen class
262 *
263 * @param bool $classes Body classes.
264 * @return array
265 */
266 public function add_loading_classes( $classes ) {
267
268 if ( ( wpbc_is_setup_wizard_page() ) && ( $this->is_full_screen ) ) {
269 $classes .= ' wpbc_admin_full_screen';
270 }
271
272 return $classes;
273 }
274 }
275 add_action('wpbc_menu_created', array( new WPBC_Page_AJX_Setup_Wizard() , '__construct') ); // Executed after creation of Menu
276
277
278 /**
279 * Make Setup Status Reset or Complete from URL
280 *
281 * @return bool
282 */
283 function wpbc_setup_wizard_page__force_in_get() {
284
285 // Se it as DONE
286 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
287 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'completed' === $_REQUEST['wpbc_setup_wizard'] ) {
288
289 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
290 $setup_steps->db__set_all_steps_as( true );
291 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
292
293 return true;
294 }
295
296 // Reset
297 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
298 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'reset' === $_REQUEST['wpbc_setup_wizard'] ) {
299
300 // -------------------------------------------------------------------------------------------------------------
301 // == Request == -> $_REQUEST['all_ajx_params']['page_num'], $_REQUEST['all_ajx_params']['page_items_count'], ...
302 // -------------------------------------------------------------------------------------------------------------
303 $user_request = new WPBC_AJX__REQUEST( array(
304 'db_option_name' => 'booking_setup_wizard_page_request_params',
305 'user_id' => wpbc_get_current_user_id(),
306 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
307 )
308 );
309 // Delete from DB
310 $is_reseted = $user_request->user_request_params__db_delete();
311
312 // Clear All Steps Mark as Undone
313 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
314 $setup_steps->db__set_all_steps_as( false );
315 update_bk_option( 'booking_wizard_data', array() );
316 wpbc_setup_wizard__set_full_screen_mode_for_current_user( true );
317
318 return true;
319 }
320
321 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
322 $steps_arr = $setup_steps->get_steps_arr();
323 $request_step = '';
324
325 if ( 'On' === get_bk_option( 'booking_setup_wizard_page_is_completed' ) ) {
326 // A completed wizard has no authority over the administrator's later Full Screen preference.
327 return true;
328 }
329
330 if ( wpbc_is_setup_wizard_page() ) {
331 wpbc_setup_wizard__set_full_screen_mode_for_current_user( true );
332 }
333
334 $is_external_setup_flow_started = $setup_steps->db__is_step_completed( 'bookings_types' );
335
336 // Persist the real setup step when the user lands on an external WPBC admin page.
337 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
338 if ( isset( $_REQUEST['wpbc_setup_step'] ) ) {
339 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
340 $request_step_from_request = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) );
341 if ( isset( $steps_arr[ $request_step_from_request ] ) ) {
342 $request_step = $request_step_from_request;
343 $setup_steps->db__save_current_step_name( $request_step );
344 wpbc_setup_wizard__set_full_screen_mode_for_current_user( ( ! wpbc_setup_wizard__is_internal_step( $request_step ) ) && ( 'get_started' !== $request_step ) );
345 }
346 }
347
348 if ( $is_external_setup_flow_started && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_request' ) ) {
349 $detected_step = wpbc_setup_wizard__detect_step_from_admin_request();
350 if ( empty( $request_step ) && ! empty( $detected_step ) && isset( $steps_arr[ $detected_step ] ) ) {
351 $setup_steps->db__save_current_step_name( $detected_step );
352 wpbc_setup_wizard__set_full_screen_mode_for_current_user( ! wpbc_setup_wizard__is_internal_step( $detected_step ) );
353 }
354 }
355
356 $is_ajax_request = ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX );
357
358 // Existing settings pages submit their own forms. This flag lets the setup bar remember that save across reloads.
359 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
360 if ( isset( $_REQUEST['wpbc_setup_saved_step'] ) && ! $is_ajax_request ) {
361 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
362 $saved_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_saved_step'] ) );
363 if ( isset( $steps_arr[ $saved_step ] ) ) {
364 $setup_steps->db__set_step_as_saved( $saved_step, true );
365 $setup_steps->db__save_current_step_name( $saved_step );
366
367 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
368 $continue_after_save = isset( $_REQUEST['wpbc_setup_continue_after_save'] )
369 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
370 ? sanitize_text_field( wp_unslash( $_REQUEST['wpbc_setup_continue_after_save'] ) )
371 : '';
372 if ( '1' === $continue_after_save ) {
373 wpbc_redirect( $setup_steps->get_step_continue_url( $saved_step ) );
374 exit;
375 }
376 }
377 }
378
379 // Continue from an existing WPBC settings page to the next setup target.
380 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
381 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'continue' === $_REQUEST['wpbc_setup_wizard'] ) {
382
383 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
384 $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '';
385 if ( ! wp_verify_nonce( $nonce, 'wpbc_settings_url_nonce' ) ) {
386 return false;
387 }
388
389 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
390 $steps_arr = $setup_steps->get_steps_arr();
391 $current_step = $setup_steps->get_saved_current_step_name();
392 $has_explicit_step_context = false;
393
394 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
395 if ( isset( $_REQUEST['wpbc_setup_step'] ) ) {
396 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
397 $request_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) );
398 if ( isset( $steps_arr[ $request_step ] ) ) {
399 $current_step = $request_step;
400 $has_explicit_step_context = true;
401 }
402 }
403
404 // Prefer the step detected on the page that rendered the setup bar. This avoids stale saved state taking over.
405 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
406 if ( isset( $_REQUEST['wpbc_setup_from_page_step'] ) ) {
407 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
408 $from_page_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_from_page_step'] ) );
409 if ( isset( $steps_arr[ $from_page_step ] ) ) {
410 $current_step = $from_page_step;
411 $has_explicit_step_context = true;
412 if ( 'form_structure' === $current_step ) {
413 $setup_steps->db__set_step_as_saved( $current_step, true );
414 }
415 }
416 }
417
418 if ( ( ! $has_explicit_step_context ) && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_url' ) ) {
419 $referer_step = wpbc_setup_wizard__detect_step_from_admin_url( wp_get_referer() );
420 if ( ! empty( $referer_step ) && isset( $steps_arr[ $referer_step ] ) ) {
421 $current_step = $referer_step;
422 if ( 'form_structure' === $current_step ) {
423 $setup_steps->db__set_step_as_saved( $current_step, true );
424 }
425 }
426 }
427
428 $setup_steps->db__save_current_step_name( $current_step );
429
430 if (
431 isset( $steps_arr[ $current_step ] )
432 && 'manual_save_required' === $setup_steps->get_step_save_behavior( $current_step )
433 && ! $setup_steps->db__is_step_saved( $current_step )
434 ) {
435 wpbc_redirect( add_query_arg( 'wpbc_setup_save_required', '1', $setup_steps->get_step_target_url( $current_step ) ) );
436 exit;
437 }
438
439 if ( isset( $steps_arr[ $current_step ] ) ) {
440 $setup_steps->db__set_step_as_completed( $current_step );
441 }
442
443 $next_step = isset( $steps_arr[ $current_step ]['next'] ) ? $steps_arr[ $current_step ]['next'] : '';
444 if ( ( empty( $next_step ) || ( 'welcome' === $next_step ) ) && function_exists( 'wpbc_setup_wizard__get_next_step_name' ) ) {
445 $route_next_step = wpbc_setup_wizard__get_next_step_name( $current_step );
446 if ( ! empty( $route_next_step ) && isset( $steps_arr[ $route_next_step ] ) ) {
447 $next_step = $route_next_step;
448 }
449 }
450
451 if ( empty( $next_step ) || ( 'welcome' === $next_step ) ) {
452 if ( 'get_started' === $current_step || 'complete' === $setup_steps->get_step_save_behavior( $current_step ) ) {
453 $setup_steps->db__set_all_steps_as( true );
454 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
455 wpbc_redirect( wpbc_get_bookings_url() );
456 exit;
457 }
458
459 if ( 'get_started' !== $current_step ) {
460 $fallback_step = $setup_steps->get_active_step_name();
461 if (
462 ( ! empty( $fallback_step ) )
463 && isset( $steps_arr[ $fallback_step ] )
464 && ( $fallback_step !== $current_step )
465 && ! $setup_steps->db__is_step_completed( $fallback_step )
466 ) {
467 $setup_steps->db__save_current_step_name( $fallback_step );
468 wpbc_redirect( $setup_steps->get_step_target_url( $fallback_step ) );
469 exit;
470 }
471 }
472
473 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
474 wpbc_redirect( wpbc_get_bookings_url() );
475 exit;
476 }
477
478 $setup_steps->db__reset_steps_from( $next_step );
479
480 $request_params_to_save = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();
481 if ( ! is_array( $request_params_to_save ) ) {
482 $request_params_to_save = wpbc_setup_wizard_page__get__request_values__default();
483 }
484 $request_params_to_save['current_step'] = $next_step;
485 if (
486 isset( $steps_arr[ $next_step ] )
487 && 'manual_save_required' === $setup_steps->get_step_save_behavior( $next_step )
488 && ! $setup_steps->db__is_step_completed( $next_step )
489 ) {
490 $setup_steps->db__set_step_as_saved( $next_step, false );
491 }
492
493 $user_request = new WPBC_AJX__REQUEST( array(
494 'db_option_name' => 'booking_setup_wizard_page_request_params',
495 'user_id' => wpbc_get_current_user_id(),
496 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
497 )
498 );
499 $user_request->user_request_params__db_save( $request_params_to_save );
500
501 wpbc_redirect( $setup_steps->get_step_target_url( $next_step ) );
502 exit;
503 }
504
505 // In the guided setup architecture, Step 5+ is configured on existing WPBC admin pages.
506 if (
507 wpbc_is_setup_wizard_page()
508 && ( ! ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) )
509 ) {
510 $current_step = $setup_steps->get_saved_current_step_name();
511
512 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
513 if ( isset( $_REQUEST['current_step'] ) ) {
514 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
515 $request_step = sanitize_key( wp_unslash( $_REQUEST['current_step'] ) );
516 if ( isset( $steps_arr[ $request_step ] ) ) {
517 $current_step = $request_step;
518 }
519 }
520
521 if (
522 isset( $steps_arr[ $current_step ]['is_external'] )
523 && $steps_arr[ $current_step ]['is_external']
524 ) {
525 wpbc_redirect( $setup_steps->get_step_target_url( $current_step ) );
526 exit;
527 }
528 }
529
530 return false;
531 }
532 add_action( 'init', 'wpbc_setup_wizard_page__force_in_get' );
533