PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
11.8.3 11.8.2 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 All 203 releases
booking / includes / page-setup / setup__page.php

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

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