PluginProbe
Booking Calendar / 11.3
Booking Calendar v11.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.3, at includes/page-setup/setup__page.php

516 lines 25.4 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( false );
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 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
327 return true;
328 }
329 $is_external_setup_flow_started = $setup_steps->db__is_step_completed( 'bookings_types' );
330
331 // Persist the real setup step when the user lands on an external WPBC admin page.
332 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
333 if ( isset( $_REQUEST['wpbc_setup_step'] ) ) {
334 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
335 $request_step_from_request = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) );
336 if ( isset( $steps_arr[ $request_step_from_request ] ) ) {
337 $request_step = $request_step_from_request;
338 $setup_steps->db__save_current_step_name( $request_step );
339 wpbc_setup_wizard__set_full_screen_mode_for_current_user( ( ! wpbc_setup_wizard__is_internal_step( $request_step ) ) && ( 'get_started' !== $request_step ) );
340 }
341 }
342
343 if ( $is_external_setup_flow_started && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_request' ) ) {
344 $detected_step = wpbc_setup_wizard__detect_step_from_admin_request();
345 if ( empty( $request_step ) && ! empty( $detected_step ) && isset( $steps_arr[ $detected_step ] ) ) {
346 $setup_steps->db__save_current_step_name( $detected_step );
347 wpbc_setup_wizard__set_full_screen_mode_for_current_user( ! wpbc_setup_wizard__is_internal_step( $detected_step ) );
348 }
349 }
350
351 // Existing settings pages submit their own forms. This flag lets the setup bar remember that save across reloads.
352 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
353 if ( isset( $_REQUEST['wpbc_setup_saved_step'] ) ) {
354 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
355 $saved_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_saved_step'] ) );
356 if ( isset( $steps_arr[ $saved_step ] ) ) {
357 $setup_steps->db__set_step_as_saved( $saved_step, true );
358 $setup_steps->db__save_current_step_name( $saved_step );
359 }
360 }
361
362 // Continue from an existing WPBC settings page to the next setup target.
363 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
364 if ( isset( $_REQUEST['wpbc_setup_wizard'] ) && 'continue' === $_REQUEST['wpbc_setup_wizard'] ) {
365
366 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
367 $nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : '';
368 if ( ! wp_verify_nonce( $nonce, 'wpbc_settings_url_nonce' ) ) {
369 return false;
370 }
371
372 $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
373 $steps_arr = $setup_steps->get_steps_arr();
374 $current_step = $setup_steps->get_saved_current_step_name();
375 $has_explicit_step_context = false;
376
377 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
378 if ( isset( $_REQUEST['wpbc_setup_step'] ) ) {
379 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
380 $request_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_step'] ) );
381 if ( isset( $steps_arr[ $request_step ] ) ) {
382 $current_step = $request_step;
383 $has_explicit_step_context = true;
384 }
385 }
386
387 // Prefer the step detected on the page that rendered the setup bar. This avoids stale saved state taking over.
388 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
389 if ( isset( $_REQUEST['wpbc_setup_from_page_step'] ) ) {
390 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
391 $from_page_step = sanitize_key( wp_unslash( $_REQUEST['wpbc_setup_from_page_step'] ) );
392 if ( isset( $steps_arr[ $from_page_step ] ) ) {
393 $current_step = $from_page_step;
394 $has_explicit_step_context = true;
395 if ( 'form_structure' === $current_step ) {
396 $setup_steps->db__set_step_as_saved( $current_step, true );
397 }
398 }
399 }
400
401 if ( ( ! $has_explicit_step_context ) && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_url' ) ) {
402 $referer_step = wpbc_setup_wizard__detect_step_from_admin_url( wp_get_referer() );
403 if ( ! empty( $referer_step ) && isset( $steps_arr[ $referer_step ] ) ) {
404 $current_step = $referer_step;
405 if ( 'form_structure' === $current_step ) {
406 $setup_steps->db__set_step_as_saved( $current_step, true );
407 }
408 }
409 }
410
411 $setup_steps->db__save_current_step_name( $current_step );
412
413 if (
414 isset( $steps_arr[ $current_step ] )
415 && 'manual_save_required' === $setup_steps->get_step_save_behavior( $current_step )
416 && ! $setup_steps->db__is_step_saved( $current_step )
417 ) {
418 wpbc_redirect( add_query_arg( 'wpbc_setup_save_required', '1', $setup_steps->get_step_target_url( $current_step ) ) );
419 exit;
420 }
421
422 if ( isset( $steps_arr[ $current_step ] ) ) {
423 $setup_steps->db__set_step_as_completed( $current_step );
424 }
425
426 $next_step = isset( $steps_arr[ $current_step ]['next'] ) ? $steps_arr[ $current_step ]['next'] : '';
427 if ( ( empty( $next_step ) || ( 'welcome' === $next_step ) ) && function_exists( 'wpbc_setup_wizard__get_next_step_name' ) ) {
428 $route_next_step = wpbc_setup_wizard__get_next_step_name( $current_step );
429 if ( ! empty( $route_next_step ) && isset( $steps_arr[ $route_next_step ] ) ) {
430 $next_step = $route_next_step;
431 }
432 }
433
434 if ( empty( $next_step ) || ( 'welcome' === $next_step ) ) {
435 if ( 'get_started' === $current_step || 'complete' === $setup_steps->get_step_save_behavior( $current_step ) ) {
436 $setup_steps->db__set_all_steps_as( true );
437 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
438 wpbc_redirect( wpbc_get_bookings_url() );
439 exit;
440 }
441
442 if ( 'get_started' !== $current_step ) {
443 $fallback_step = $setup_steps->get_active_step_name();
444 if (
445 ( ! empty( $fallback_step ) )
446 && isset( $steps_arr[ $fallback_step ] )
447 && ( $fallback_step !== $current_step )
448 && ! $setup_steps->db__is_step_completed( $fallback_step )
449 ) {
450 $setup_steps->db__save_current_step_name( $fallback_step );
451 wpbc_redirect( $setup_steps->get_step_target_url( $fallback_step ) );
452 exit;
453 }
454 }
455
456 wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
457 wpbc_redirect( wpbc_get_bookings_url() );
458 exit;
459 }
460
461 $setup_steps->db__reset_steps_from( $next_step );
462
463 $request_params_to_save = wpbc_setup_wizard_page__get_cleaned_params__saved_request_default();
464 if ( ! is_array( $request_params_to_save ) ) {
465 $request_params_to_save = wpbc_setup_wizard_page__get__request_values__default();
466 }
467 $request_params_to_save['current_step'] = $next_step;
468 if (
469 isset( $steps_arr[ $next_step ] )
470 && 'manual_save_required' === $setup_steps->get_step_save_behavior( $next_step )
471 && ! $setup_steps->db__is_step_completed( $next_step )
472 ) {
473 $setup_steps->db__set_step_as_saved( $next_step, false );
474 }
475
476 $user_request = new WPBC_AJX__REQUEST( array(
477 'db_option_name' => 'booking_setup_wizard_page_request_params',
478 'user_id' => wpbc_get_current_user_id(),
479 'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure()
480 )
481 );
482 $user_request->user_request_params__db_save( $request_params_to_save );
483
484 wpbc_redirect( $setup_steps->get_step_target_url( $next_step ) );
485 exit;
486 }
487
488 // In the guided setup architecture, Step 5+ is configured on existing WPBC admin pages.
489 if (
490 wpbc_is_setup_wizard_page()
491 && ( ! ( function_exists( 'wp_doing_ajax' ) && wp_doing_ajax() ) )
492 ) {
493 $current_step = $setup_steps->get_saved_current_step_name();
494
495 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
496 if ( isset( $_REQUEST['current_step'] ) ) {
497 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
498 $request_step = sanitize_key( wp_unslash( $_REQUEST['current_step'] ) );
499 if ( isset( $steps_arr[ $request_step ] ) ) {
500 $current_step = $request_step;
501 }
502 }
503
504 if (
505 isset( $steps_arr[ $current_step ]['is_external'] )
506 && $steps_arr[ $current_step ]['is_external']
507 ) {
508 wpbc_redirect( $setup_steps->get_step_target_url( $current_step ) );
509 exit;
510 }
511 }
512
513 return false;
514 }
515 add_action( 'init', 'wpbc_setup_wizard_page__force_in_get' );
516