PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 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 All 204 releases
← All changes | includes/page-setup/setup_ajax.php +87 -366 10.15.611.8.4 View file →
@@ -1,4 +1,4 @@
1 1 <?php /**
2 2 * @version 1.0
3 3 * @description Ajax and Requests Structure for WPBC_AJX__Setup__Ajax_Request
4 4 * @category Setup Class
@@ -34,15 +34,9 @@
34 34 'save_and_continue__welcome',
35 35 'save_and_continue__general_info',
36 36 'save_and_continue__date_time_formats',
37 37 'save_and_continue__bookings_types',
38 - 'save_and_continue__form_structure',
39 - 'load_form_template',
40 - 'save_and_continue__cal_availability',
41 - 'save_and_continue__color_theme',
42 - 'save_and_continue__optional_other_settings',
43 - 'save_and_continue__wizard_publish',
44 - 'save_and_continue__get_started'
38 + 'redirect_to_setup_step'
45 39 ),
46 40 'default' => 'none'
47 41 ),
48 42 'current_step' => array( 'validate' => 's', 'default' => '' ),
@@ -162,14 +156,48 @@
162 156 public function define_ajax_hook(){
163 157
164 158 // Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php
165 159 add_action( 'wp_ajax_' . 'WPBC_AJX_SETUP_WIZARD_PAGE', array( $this, 'ajax_' . 'WPBC_AJX_SETUP_WIZARD_PAGE' ) ); // Admin & Client (logged in usres)
160 + add_action( 'wp_ajax_' . 'WPBC_AJX_SETUP_WIZARD_MARK_STEP_SAVED', array( $this, 'ajax_' . 'WPBC_AJX_SETUP_WIZARD_MARK_STEP_SAVED' ) );
166 161
167 162 // Ajax Handlers for actions
168 163 // add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in)
169 164 }
170 165
166 + /**
167 + * Ajax - mark an external setup step as saved after an existing settings page saves successfully.
168 + *
169 + * @return void
170 + */
171 + public function ajax_WPBC_AJX_SETUP_WIZARD_MARK_STEP_SAVED() {
171 172
173 + $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
174 + if ( ! wp_verify_nonce( $nonce, 'wpbc_setup_wizard_mark_step_saved' ) ) {
175 + wp_send_json_error( array( 'message' => __( 'Security check failed.', 'booking' ) ) );
176 + }
177 +
178 + $step_name = isset( $_POST['wpbc_setup_step'] ) ? sanitize_key( wp_unslash( $_POST['wpbc_setup_step'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing
179 + $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
180 + $steps_arr = $setup_steps->get_steps_arr();
181 +
182 + if ( empty( $step_name ) && function_exists( 'wpbc_setup_wizard__detect_step_from_admin_url' ) ) {
183 + $referer_step = wpbc_setup_wizard__detect_step_from_admin_url( wp_get_referer() );
184 + if ( ! empty( $referer_step ) && isset( $steps_arr[ $referer_step ] ) ) {
185 + $step_name = $referer_step;
186 + }
187 + }
188 +
189 + if ( empty( $step_name ) || ! isset( $steps_arr[ $step_name ] ) ) {
190 + wp_send_json_error( array( 'message' => __( 'Unknown setup step.', 'booking' ) ) );
191 + }
192 +
193 + $setup_steps->db__set_step_as_saved( $step_name, true );
194 + $setup_steps->db__save_current_step_name( $step_name );
195 +
196 + wp_send_json_success( array( 'step' => $step_name ) );
197 + }
198 +
199 +
172 200 /**
173 201 * Ajax - Get Listing Data and Response to JS script
174 202 */
175 203 public function ajax_WPBC_AJX_SETUP_WIZARD_PAGE() {
@@ -212,10 +240,13 @@
212 240 // Steps
213 241 //--------------------------------------------------------------------------------------------------------------
214 242 $data_arr['current_step'] = ( ! empty( $cleaned_request_params['current_step'] )
215 243 ? $cleaned_request_params['current_step']
216 - : $setup_steps->get_active_step_name() ); // e.g. 'general_info' or 'optional_other_settings'
244 + : $setup_steps->get_active_step_name() ); // e.g. 'general_info' or 'date_availability'
217 245 $data_arr['steps'] = $setup_steps->get_steps_arr();
246 + if ( ! isset( $data_arr['steps'][ $data_arr['current_step'] ] ) ) {
247 + $data_arr['current_step'] = $setup_steps->get_active_step_name();
248 + }
218 249
219 250 // -------------------------------------------------------------------------------------------------------------
220 251 // Get Wizard history
221 252 // -------------------------------------------------------------------------------------------------------------
@@ -234,8 +265,10 @@
234 265 case 'make_reset':
235 266
236 267 $is_reseted = $user_request->user_request_params__db_delete(); // Delete from DB
237 268
269 + wpbc_setup_wizard__set_full_screen_mode_for_current_user( true );
270 +
238 271 $cleaned_request_params['do_action'] = $is_reseted ? 'reset_done' : 'reset_error';
239 272
240 273 $cleaned_request_params = wpbc_setup_wizard_page__get__request_values__default();
241 274
@@ -253,8 +286,9 @@
253 286 $data_arr['current_step'] = 'welcome';
254 287 // $data_arr['redirect_url'] = wpbc_get_settings_url();
255 288 $data_arr['redirect_url'] = wpbc_get_bookings_url();
256 289
290 + wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
257 291 $setup_steps->db__set_all_steps_as( true ); // Mark All Steps as Done
258 292
259 293 break;
260 294
@@ -300,9 +334,22 @@
300 334 $cleaned_data = wpbc_template__bookings_types__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
301 335
302 336 // Legacy update booking form and dates selection, as some other options (recurrent time)....
303 337 wpbc_setup__update__bookings_types( $cleaned_data );
338 + $booking_wizard_data_arr['save_and_continue__bookings_types'] = $cleaned_data;
339 + update_bk_option( 'booking_wizard_data', $booking_wizard_data_arr );
304 340
341 + /**
342 + * Fires after the validated Booking Type configuration is applied and saved.
343 + *
344 + * Optional modules can synchronize presentation state from the selected
345 + * workflow without entering the Setup Wizard validation or mutation engine.
346 + *
347 + * @param array $cleaned_data Validated Setup Wizard booking-type data.
348 + */
349 + do_action( 'wpbc_setup_wizard_booking_type_saved', $cleaned_data );
350 + $setup_steps = new WPBC_SETUP_WIZARD_STEPS();
351 +
305 352 // FixIn: 10.7.1.3. // FixIn: 10.15.1.1.
306 353 $cleaned_data_booking_feedback_arr = get_bk_option( 'booking_feedback__send_email' );
307 354 if (! empty($cleaned_data_booking_feedback_arr)){
308 355 if ( 'On' === $cleaned_data_booking_feedback_arr['wpbc_swp_accept_send'] ) {
@@ -309,162 +356,44 @@
309 356 $cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr , array( 'type' => 'Type: ' . $cleaned_data ['wpbc_swp_booking_types'] ) );
310 357 if ( 'time_slots_appointments' === $cleaned_data ['wpbc_swp_booking_types'] ) {
311 358 $cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr, array( 'appointments_type' => 'Appointment: ' . $cleaned_data ['wpbc_swp_booking_appointments_type'] ) );
312 359 }
313 - wpbc_setup_feedback__send_email( $cleaned_data_booking_feedback_arr );
360 + if ( ! WPBC_IS_PLAYGROUND ) {
361 + wpbc_setup_feedback__send_email( $cleaned_data_booking_feedback_arr );
362 + }
314 363 update_bk_option( 'booking_feedback__after_send', $cleaned_data_booking_feedback_arr );
315 364 delete_bk_option( 'booking_feedback__send_email' );
316 365 }
317 366 }
318 367
319 - $is_bfb_enabled = (bool) WPBC_Frontend_Settings::is_bfb_enabled( null );
320 - if ( $is_bfb_enabled ) {
321 - $or_sep_url = ( defined( 'WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR_URL' ) ) ? (string) WPBC_BFB_TEMPLATE_SEARCH_OR_SEPARATOR_URL : '^';
322 - if ( '' === $or_sep_url ) {
323 - $or_sep_url = '^';
324 - }
325 - $template_search_key = '';
326 - if ( 'full_days_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
327 - $template_search_key = 'full-days' . $or_sep_url . 'dates_form';
328 - }
329 - if ( 'time_slots_appointments' === $cleaned_data['wpbc_swp_booking_types'] ) {
330 - if ( 'rangetime' !== $cleaned_data['wpbc_swp_booking_appointments_type'] ) {
331 - $template_search_key = 'appointments';// . $or_sep_url . 'duration';
332 - } else {
333 - $template_search_key = 'time+slots' . $or_sep_url . 'times';
334 - }
335 - }
336 - if ( 'changeover_multi_dates_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
337 - $template_search_key = 'changeover' . $or_sep_url . 'triangles';
338 - }
339 - // JavaScript redirect: wpbc_redirect( 'url' ); // PHP: redirect:.
340 - // wp_redirect( admin_url( 'admin.php?page=wpbc-settings&tab=builder_booking_form&auto_open_template=' . $cleaned_data ) );
341 -
342 - $cleaned_request_params['do_action'] = 'auto_open_template';
343 - $data_arr['redirect_url'] = admin_url( 'admin.php?page=wpbc-settings&tab=builder_booking_form&auto_open_template=' . $template_search_key );
344 - $data_arr['current_step'] = 'cal_availability';
345 - // Mark as completed, Type of bookings and Form structure!
346 - $setup_steps->db__set_step_as_completed( 'bookings_types' );
347 - $setup_steps->db__set_step_as_completed( 'form_structure' );
348 - break;
349 - }
350 -
351 -
352 - // -------------------------------------------------------------------------------------------------
353 - // Save selected option at the next step for paid versions
354 - // -------------------------------------------------------------------------------------------------
355 - $booking_wizard_data_arr[ 'load_form_template' ] = array();
356 - if ( class_exists( 'wpdev_bk_personal' ) ) {
357 - if ( 'full_days_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
358 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|hints-dev';
359 - }
360 - if ( 'time_slots_appointments' === $cleaned_data['wpbc_swp_booking_types'] ) {
361 - if ( 'durationtime' === $cleaned_data['wpbc_swp_booking_appointments_type'] ) {
362 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|appointments_service_c'; // FixIn: 10.7.1.4.
363 - } else {
364 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|appointments30'; // FixIn: 10.7.1.4.
365 - }
366 - }
367 - if ( 'changeover_multi_dates_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
368 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|wizard';
369 - }
370 - }
371 - // -------------------------------------------------------------------------------------------------
372 368 }
373 369
374 - $setup_steps->db__set_step_as_completed( 'bookings_types' );
375 - break;
376 -
377 - case 'save_and_continue__form_structure':
378 -
379 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
380 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
381 - $cleaned_data = wpbc_template__form_structure__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
382 - wpbc_setup__update__form_structure( $cleaned_data );
370 + $setup_steps->db__set_step_as_completed( 'bookings_types' );
371 + if ( ! empty( $cleaned_data ) ) {
372 + $data_arr['current_step'] = wpbc_setup_wizard__get_first_profile_step();
373 + $current_steps_arr = $setup_steps->get_steps_arr();
374 + $is_form_builder_handoff = array( 'form_structure' ) === wpbc_setup_wizard__get_profile_route();
375 +
376 + if ( $is_form_builder_handoff ) {
377 + // Form Builder is the fifth and final temporary Setup step.
378 + $setup_steps->db__set_step_as_completed( 'form_structure' );
379 + wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
380 + } else {
381 + wpbc_setup_wizard__set_full_screen_mode_for_current_user( true );
382 + $setup_steps->db__reset_steps_from( $data_arr['current_step'] );
383 + if (
384 + isset( $current_steps_arr[ $data_arr['current_step'] ] )
385 + && 'manual_save_required' === $setup_steps->get_step_save_behavior( $data_arr['current_step'] )
386 + ) {
387 + $setup_steps->db__set_step_as_saved( $data_arr['current_step'], false );
388 + }
389 + }
390 + $data_arr['redirect_url'] = $setup_steps->get_step_target_url( $data_arr['current_step'] );
391 + $data_arr['steps'] = $current_steps_arr;
392 + $cleaned_request_params['do_action'] = 'redirect_to_setup_step';
383 393 }
384 -
385 - $setup_steps->db__set_step_as_completed( 'form_structure' );
386 394 break;
387 395
388 - case 'load_form_template':
389 -
390 - if (
391 - ( 'form_structure' === $data_arr['current_step'] )
392 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
393 - ){
394 - $cleaned_data = wpbc_template__form_structure__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
395 - wpbc_setup__update__form_structure( $cleaned_data );
396 - }
397 - if (
398 - ( 'cal_availability' === $data_arr['current_step'] )
399 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
400 - ){
401 - $cleaned_data = wpbc_template__cal_availability__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
402 - wpbc_setup__update__cal_availability( $cleaned_data );
403 - }
404 - if (
405 - ( 'color_theme' === $data_arr['current_step'] )
406 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
407 - ){
408 - $cleaned_data = wpbc_template__color_theme__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
409 - wpbc_setup__update__color_theme( $cleaned_data );
410 - }
411 -
412 - break;
413 -
414 - case 'save_and_continue__cal_availability':
415 -
416 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
417 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
418 - $cleaned_data = wpbc_template__cal_availability__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
419 - wpbc_setup__update__cal_availability( $cleaned_data );
420 - }
421 -
422 - $setup_steps->db__set_step_as_completed( 'cal_availability' );
423 - break;
424 -
425 - case 'save_and_continue__color_theme':
426 -
427 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
428 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
429 - $cleaned_data = wpbc_template__color_theme__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
430 - wpbc_setup__update__color_theme( $cleaned_data );
431 - }
432 -
433 - $setup_steps->db__set_step_as_completed( 'color_theme' );
434 - break;
435 -
436 - case 'save_and_continue__optional_other_settings':
437 -
438 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
439 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
440 - $cleaned_data = wpbc_template__optional_other_settings__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
441 - wpbc_setup__update__optional_other_settings( $cleaned_data );
442 - }
443 - $setup_steps->db__set_step_as_completed( 'optional_other_settings' );
444 - break;
445 -
446 - case 'save_and_continue__wizard_publish':
447 -
448 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
449 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
450 - $cleaned_data = wpbc_template__wizard_publish__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
451 - wpbc_setup__update__wizard_publish( $cleaned_data );
452 - }
453 - $setup_steps->db__set_step_as_completed( 'wizard_publish' );
454 - break;
455 -
456 - case 'save_and_continue__get_started':
457 -
458 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
459 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
460 - $cleaned_data = wpbc_template__get_started__action_validate_data( $_POST['all_ajx_params']['step_data'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
461 - wpbc_setup__update__get_started( $cleaned_data );
462 - }
463 - $setup_steps->db__set_step_as_completed( 'get_started' );
464 - break;
465 -
466 -
467 396 default:
468 397 // Default
469 398 }
470 399
@@ -472,189 +401,16 @@
472 401 // Other
473 402 //--------------------------------------------------------------------------------------------------------------
474 403 $data_arr['steps_is_done'] = $setup_steps->db__get_steps_is_done();
475 404 $data_arr['left_navigation'] = wpbc_setup_wizard_page__get_left_navigation_menu_arr();
476 - $data_arr['plugin_menu__setup_progress'] = $setup_steps->get_plugin_menu_title__setup_progress();
405 + $data_arr['plugin_menu__setup_progress'] = $setup_steps->get_plugin_menu_title__setup_progress( $data_arr['current_step'] );
477 406
478 - //--------------------------------------------------------------------------------------------------------------
479 - // Load Calendar depend on Step
480 - //--------------------------------------------------------------------------------------------------------------
407 + // External setup steps are now configured on their existing admin pages, so the setup-page AJAX response does
408 + // not need to embed their duplicated calendars or forms.
481 409 $data_arr['ui'] = array();
410 + $data_arr['calendar_force_load'] = '';
482 411
483 - switch ( $data_arr['current_step'] ) {
484 412
485 - case 'form_structure':
486 - $data_arr['calendar_force_load'] = '';
487 -
488 - if ( 'save_and_continue__bookings_types' === $cleaned_request_params['do_action'] ) {
489 - // We need to reload the calendar skins, because at the previous step 'Booking Types' we updated the calendar skins relative to selected options
490 - ob_start();
491 - ?>
492 - <script type="text/javascript">
493 - jQuery( document ).ready( function () {
494 - wpbc__calendar__change_skin( '<?php echo esc_url( WPBC_PLUGIN_URL . get_bk_option( 'booking_skin' ) ); ?>' );
495 - wpbc__css__change_skin( '<?php echo esc_url( WPBC_PLUGIN_URL . get_bk_option( 'booking_timeslot_picker_skin' ) ); ?>' );
496 - } );
497 - </script><?php
498 - $data_arr['calendar_force_load'] .= ob_get_clean();
499 - }
500 - $data_arr['calendar_force_load'] .= wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
501 - break;
502 -
503 - case 'cal_availability':
504 -
505 - $data_arr['calendar_force_load'] = wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
506 -
507 - // -----------------------------------------------------------------------------------------------------
508 - // == UNAVAILABLE WeekDays ==
509 - // -----------------------------------------------------------------------------------------------------
510 - $data_arr['ui']['booking_unavailable_day'] = array();
511 - for ( $wdi = 0; $wdi < 7; $wdi ++ ) {
512 - if ( get_bk_option( 'booking_unavailable_day' . $wdi ) == 'On' ) {
513 - $data_arr['ui']['booking_unavailable_day'][] = $wdi;
514 - }
515 - }
516 -
517 - /**
518 - * $unavailable_from_today_arr = [
519 - * booking_unavailable_days_num_from_today = "540m"
520 - * booking_unavailable_days_num_from_today__hint = ": 2025-01-25 15:19 - 2025-01-26 00:18:42"
521 - * booking_available_days_num_from_today = "0"
522 - * booking_available_days_num_from_today__hint = ": 26 Jan, 2025 - ..."
523 - * ]
524 - */
525 - $unavailable_from_today_arr = wpbc_get_unavailable_from_today_hints_arr();
526 -
527 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = $unavailable_from_today_arr['booking_unavailable_days_num_from_today'];
528 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = $unavailable_from_today_arr['booking_unavailable_days_num_from_today__hint'];
529 - $data_arr['ui']['booking_available_days_num_from_today'] = $unavailable_from_today_arr['booking_available_days_num_from_today'];
530 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = $unavailable_from_today_arr['booking_available_days_num_from_today__hint'];
531 -if(0){
532 - // -----------------------------------------------------------------------------------------------------
533 - // == UNAVAILABLE Today days ==
534 - // -----------------------------------------------------------------------------------------------------
535 - // FixIn: 10.8.1.4.
536 - $last_unavailable_date = '';
537 - if ( 'm' === substr( get_bk_option( 'booking_unavailable_days_num_from_today' ), - 1 ) ) {
538 - // -------------------------------------------------------------------------------------------------
539 - // == Minutes ==
540 - // -------------------------------------------------------------------------------------------------
541 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = intval( get_bk_option( 'booking_unavailable_days_num_from_today' ) );
542 -
543 - // Hints.
544 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': <span style="text-transform: lowercase;font-size:0.9em;">'
545 - . __( 'None', 'booking' ) . '</span>';
546 - if ( ! empty( $data_arr['ui']['booking_unavailable_days_num_from_today'] ) ) {
547 -
548 - $start_date_unix = strtotime( 'now' );
549 - $todate_with_wp_timezone = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d H:i' );
550 -
551 - $start_date_unix = strtotime( '+' . ( intval( $data_arr['ui']['booking_unavailable_days_num_from_today'] ) - 1 ) . ' minutes' );
552 - $max_date_with_wp_timezone = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d H:i:s' );
553 -
554 - $last_unavailable_date = $max_date_with_wp_timezone;
555 -
556 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . $todate_with_wp_timezone . ' - ' . $max_date_with_wp_timezone; // FixIn: 10.9.4.2.
557 - }
558 - $data_arr['ui']['booking_unavailable_days_num_from_today'] .= 'm';
559 - } else {
560 - // -------------------------------------------------------------------------------------------------
561 - // == Days ==
562 - // -------------------------------------------------------------------------------------------------
563 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = intval( get_bk_option( 'booking_unavailable_days_num_from_today' ) );
564 -
565 - // Hints.
566 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': <span style="text-transform: lowercase;font-size:0.9em;">' . __( 'None', 'booking' ) . '</span>';
567 -
568 - if ( 1 === $data_arr['ui']['booking_unavailable_days_num_from_today'] ) {
569 - $last_unavailable_date = wp_date( 'Y-m-d 00:00:00' );
570 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . wp_date( 'd M', strtotime( $last_unavailable_date ) );
571 - }
572 - if ( $data_arr['ui']['booking_unavailable_days_num_from_today'] > 1 ) {
573 - $last_unavailable_date = wp_date( 'Y-m-d 00:00:00', strtotime( '+' . ( $data_arr['ui']['booking_unavailable_days_num_from_today'] - 1 ) . ' days' ) );
574 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . wp_date( 'd M' ) . ' - ' . wp_date( 'd M', strtotime( $last_unavailable_date ) );
575 - }
576 - }
577 -
578 - // -----------------------------------------------------------------------------------------------------
579 - // == AVAILABLE Today days ==
580 - // -----------------------------------------------------------------------------------------------------
581 - // if ( class_exists( 'wpdev_bk_biz_m' ) ) { .
582 - $data_arr['ui']['booking_available_days_num_from_today'] = esc_js( get_bk_option( 'booking_available_days_num_from_today' ) );
583 -
584 - // Hints.
585 - // $start_available_date = ( '' === $last_unavailable_date ) ? wp_date( 'Y-m-d 00:00:00' ) : wp_date( 'Y-m-d 00:00:00', strtotime( '+1 day', strtotime( $last_unavailable_date ) ) );
586 - if ( '' === $last_unavailable_date ) {
587 - $start_date_unix = strtotime( 'now' );
588 - $todate_with_wp_timezone = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d 00:00:00' );
589 - $start_available_date = $todate_with_wp_timezone;
590 - } else {
591 - $start_available_date = $last_unavailable_date;
592 - // We use here with no WP timezone, because timezone already applied to $last_unavailable_date.
593 - $start_available_date = wpbc_datetime_localized__no_wp_timezone( strtotime( $last_unavailable_date ), 'Y-m-d 00:00:00' );
594 - }
595 -
596 -
597 - if ( empty( $data_arr['ui']['booking_available_days_num_from_today'] ) ) {
598 - $last_available_date = '';
599 - } else {
600 - // $last_available_date = wp_date( 'Y-m-d 00:00:00', strtotime( '+' . ( $data_arr['ui']['booking_available_days_num_from_today'] ) . ' days' ) );
601 - // FixIn: 10.9.6.3.
602 - $start_date_unix = strtotime( '+' . ( intval( $data_arr['ui']['booking_available_days_num_from_today'] ) - 1 ) . ' days' );
603 - $last_available_date = wpbc_datetime_localized__use_wp_timezone( gmdate( 'Y-m-d H:i:s', $start_date_unix ), 'Y-m-d 00:00:00' );
604 - }
605 -
606 - if ( ! empty( $data_arr['ui']['booking_available_days_num_from_today'] ) ) {
607 -
608 - if ( strtotime( $start_available_date ) < strtotime( $last_available_date ) ) {
609 -
610 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) ) . ' - ' . wp_date( 'd M, Y', strtotime( $last_available_date ) );
611 - } else if ( strtotime( $start_available_date ) == strtotime( $last_available_date ) ) {
612 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) );
613 - } else {
614 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': <span style="text-transform: uppercase;font-size:1.1em;">' . esc_html__( 'None', 'booking' ) . '</span><br>' .
615 - ' <span style="text-transform: lowercase;font-size:0.9em;color:#cc3a5f;">' .
616 - 'Start available' . ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) ) . '<br>' .
617 - 'Last available' . ': ' . wp_date( 'd M, Y', strtotime( $last_available_date ) ) . '</span>';
618 - }
619 - } else {
620 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) ) . ' - ...';
621 - }
622 -}
623 -
624 - $data_arr['ui']['booking_unavailable_extra_in_out'] = get_bk_option( 'booking_unavailable_extra_in_out' );
625 - $data_arr['ui']['booking_unavailable_extra_minutes_in'] = get_bk_option( 'booking_unavailable_extra_minutes_in' );
626 - $data_arr['ui']['booking_unavailable_extra_minutes_out'] = get_bk_option( 'booking_unavailable_extra_minutes_out' );
627 - $data_arr['ui']['booking_unavailable_extra_days_in'] = get_bk_option( 'booking_unavailable_extra_days_in' );
628 - $data_arr['ui']['booking_unavailable_extra_days_out'] = get_bk_option( 'booking_unavailable_extra_days_out' );
629 -
630 - break;
631 -
632 - case 'color_theme':
633 -
634 - $data_arr['calendar_force_load'] = wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
635 - $data_arr['ui']['booking_form_theme'] = get_bk_option( 'booking_form_theme' );
636 - $data_arr['ui']['booking_skin'] = get_bk_option( 'booking_skin' );
637 - $data_arr['ui']['booking_timeslot_picker_skin'] = get_bk_option( 'booking_timeslot_picker_skin' );
638 - break;
639 -
640 - case 'optional_other_settings':
641 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
642 - break;
643 -
644 - case 'wizard_publish':
645 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
646 - break;
647 -
648 - case 'get_started':
649 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
650 - break;
651 -
652 - default:
653 - $data_arr['calendar_force_load'] = '';
654 - }
655 -
656 -
657 413 // -------------------------------------------------------------------------------------------------------------
658 414 // Save Wizard history
659 415 // -------------------------------------------------------------------------------------------------------------
660 416 // Save to DB
@@ -663,49 +419,14 @@
663 419 // Ajax Transfer
664 420 $data_arr['booking_wizard_data'] = $booking_wizard_data_arr;
665 421 // -------------------------------------------------------------------------------------------------------------
666 422
667 -//TODO: delete this ?
668 -if(0){
669 -
670 - $data_arr['customize_steps'] = array();
671 - $data_arr['customize_steps']['action'] = 'none';
672 -
673 - // Actions =================================================================================================
674 -
675 - if ( 'save_calendar_additional' == $cleaned_request_params['do_action'] ) {
676 -
677 - $is_updated = update_bk_option( 'booking_max_monthes_in_calendar', $cleaned_request_params['calendar__booking_max_monthes_in_calendar'] );
678 - $is_updated = update_bk_option( 'booking_start_day_weeek', $cleaned_request_params['calendar__booking_start_day_weeek'] );
679 - }
680 -
681 - //----------------------------------------------------------------------------------------------------------
682 -
683 - // Get booking resources (sql)
684 - $resources_arr = wpbc_ajx_get_all_booking_resources_arr(); /**
685 - * Array ( [0] => Array ( [booking_type_id] => 1
686 - [title] => Standard
687 - [users] => 1
688 - [import] =>
689 - [export] =>
690 - [cost] => 25
691 - [default_form] => standard
692 - [prioritet] => 0
693 - [parent] => 0
694 - [visitors] => 2
695 - ), ... */
696 -
697 - $resources_arr_sorted = wpbc_ajx_get_sorted_booking_resources_arr( $resources_arr );
698 -
699 - $data_arr['ajx_booking_resources'] = $resources_arr_sorted;
700 -}
701 -
702 -
703 423 // -------------------------------------------------------------------------------------------------------------
704 424 // Save Status of Wizard for specific user
705 425 // -------------------------------------------------------------------------------------------------------------
706 426 if ( 'make_reset' !== $cleaned_request_params['do_action'] ) {
707 427
428 + $cleaned_request_params['current_step'] = $data_arr['current_step'];
708 429 $request_params_to_save = $cleaned_request_params;
709 430
710 431 // Do not safe such elements
711 432 unset( $request_params_to_save['ui_clicked_element_id'] );
@@ -737,5 +458,5 @@
737 458 */
738 459 if ( true ) {
739 460 $wpbc_setup_wizard_page_loading = new WPBC_AJX__Setup_Wizard__Ajax_Request;
740 461 $wpbc_setup_wizard_page_loading->define_ajax_hook();
741 -}
462 +}