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

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