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 +95 -337 10.10.111.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
@@ -250,10 +283,12 @@
250 283
251 284 case 'skip_wizard':
252 285
253 286 $data_arr['current_step'] = 'welcome';
254 - $data_arr['redirect_url'] = wpbc_get_settings_url();
287 + // $data_arr['redirect_url'] = wpbc_get_settings_url();
288 + $data_arr['redirect_url'] = wpbc_get_bookings_url();
255 289
290 + wpbc_setup_wizard__set_full_screen_mode_for_current_user( false );
256 291 $setup_steps->db__set_all_steps_as( true ); // Mark All Steps as Done
257 292
258 293 break;
259 294
@@ -296,11 +331,26 @@
296 331
297 332 // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
298 333 if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
299 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
335 +
336 + // Legacy update booking form and dates selection, as some other options (recurrent time)....
300 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 );
301 340
302 - // FixIn: 10.7.1.3.
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 +
352 + // FixIn: 10.7.1.3. // FixIn: 10.15.1.1.
303 353 $cleaned_data_booking_feedback_arr = get_bk_option( 'booking_feedback__send_email' );
304 354 if (! empty($cleaned_data_booking_feedback_arr)){
305 355 if ( 'On' === $cleaned_data_booking_feedback_arr['wpbc_swp_accept_send'] ) {
306 356 $cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr , array( 'type' => 'Type: ' . $cleaned_data ['wpbc_swp_booking_types'] ) );
@@ -306,128 +356,44 @@
306 356 $cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr , array( 'type' => 'Type: ' . $cleaned_data ['wpbc_swp_booking_types'] ) );
307 357 if ( 'time_slots_appointments' === $cleaned_data ['wpbc_swp_booking_types'] ) {
308 358 $cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr, array( 'appointments_type' => 'Appointment: ' . $cleaned_data ['wpbc_swp_booking_appointments_type'] ) );
309 359 }
310 - 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 + }
363 + update_bk_option( 'booking_feedback__after_send', $cleaned_data_booking_feedback_arr );
311 364 delete_bk_option( 'booking_feedback__send_email' );
312 365 }
313 366 }
314 367
315 - // -------------------------------------------------------------------------------------------------
316 - // Save selected option at the next step for paid versions
317 - // -------------------------------------------------------------------------------------------------
318 - $booking_wizard_data_arr[ 'load_form_template' ] = array();
319 - if ( class_exists( 'wpdev_bk_personal' ) ) {
320 - if ( 'full_days_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
321 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|hints-dev';
322 - }
323 - if ( 'time_slots_appointments' === $cleaned_data['wpbc_swp_booking_types'] ) {
324 - if ( 'durationtime' === $cleaned_data['wpbc_swp_booking_appointments_type'] ) {
325 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|appointments_service_a'; // FixIn: 10.7.1.4.
326 - } else {
327 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|appointments30'; // FixIn: 10.7.1.4.
328 - }
329 - }
330 - if ( 'changeover_multi_dates_bookings' === $cleaned_data['wpbc_swp_booking_types'] ) {
331 - $booking_wizard_data_arr['load_form_template'] ['wpbc_swp_booking_form_template_pro'] = 'pro|wizard';
332 - }
333 - }
334 - // -------------------------------------------------------------------------------------------------
335 368 }
336 369
337 - $setup_steps->db__set_step_as_completed( 'bookings_types' );
338 - break;
339 -
340 - case 'save_and_continue__form_structure':
341 -
342 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
343 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
344 - $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
345 - 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';
346 393 }
347 -
348 - $setup_steps->db__set_step_as_completed( 'form_structure' );
349 394 break;
350 395
351 - case 'load_form_template':
352 -
353 - if (
354 - ( 'form_structure' === $data_arr['current_step'] )
355 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
356 - ){
357 - $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
358 - wpbc_setup__update__form_structure( $cleaned_data );
359 - }
360 - if (
361 - ( 'cal_availability' === $data_arr['current_step'] )
362 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
363 - ){
364 - $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
365 - wpbc_setup__update__cal_availability( $cleaned_data );
366 - }
367 - if (
368 - ( 'color_theme' === $data_arr['current_step'] )
369 - && ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) )
370 - ){
371 - $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
372 - wpbc_setup__update__color_theme( $cleaned_data );
373 - }
374 -
375 - break;
376 -
377 - case 'save_and_continue__cal_availability':
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__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
382 - wpbc_setup__update__cal_availability( $cleaned_data );
383 - }
384 -
385 - $setup_steps->db__set_step_as_completed( 'cal_availability' );
386 - break;
387 -
388 - case 'save_and_continue__color_theme':
389 -
390 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
391 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
392 - $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
393 - wpbc_setup__update__color_theme( $cleaned_data );
394 - }
395 -
396 - $setup_steps->db__set_step_as_completed( 'color_theme' );
397 - break;
398 -
399 - case 'save_and_continue__optional_other_settings':
400 -
401 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
402 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
403 - $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
404 - wpbc_setup__update__optional_other_settings( $cleaned_data );
405 - }
406 - $setup_steps->db__set_step_as_completed( 'optional_other_settings' );
407 - break;
408 -
409 - case 'save_and_continue__wizard_publish':
410 -
411 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
412 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
413 - $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
414 - wpbc_setup__update__wizard_publish( $cleaned_data );
415 - }
416 - $setup_steps->db__set_step_as_completed( 'wizard_publish' );
417 - break;
418 -
419 - case 'save_and_continue__get_started':
420 -
421 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing
422 - if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) {
423 - $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
424 - wpbc_setup__update__get_started( $cleaned_data );
425 - }
426 - $setup_steps->db__set_step_as_completed( 'get_started' );
427 - break;
428 -
429 -
430 396 default:
431 397 // Default
432 398 }
433 399
@@ -435,189 +401,16 @@
435 401 // Other
436 402 //--------------------------------------------------------------------------------------------------------------
437 403 $data_arr['steps_is_done'] = $setup_steps->db__get_steps_is_done();
438 404 $data_arr['left_navigation'] = wpbc_setup_wizard_page__get_left_navigation_menu_arr();
439 - $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'] );
440 406
441 - //--------------------------------------------------------------------------------------------------------------
442 - // Load Calendar depend on Step
443 - //--------------------------------------------------------------------------------------------------------------
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.
444 409 $data_arr['ui'] = array();
410 + $data_arr['calendar_force_load'] = '';
445 411
446 - switch ( $data_arr['current_step'] ) {
447 412
448 - case 'form_structure':
449 - $data_arr['calendar_force_load'] = '';
450 -
451 - if ( 'save_and_continue__bookings_types' === $cleaned_request_params['do_action'] ) {
452 - // We need to reload the calendar skins, because at the previous step 'Booking Types' we updated the calendar skins relative to selected options
453 - ob_start();
454 - ?>
455 - <script type="text/javascript">
456 - jQuery( document ).ready( function () {
457 - wpbc__calendar__change_skin( '<?php echo esc_url( WPBC_PLUGIN_URL . get_bk_option( 'booking_skin' ) ); ?>' );
458 - wpbc__css__change_skin( '<?php echo esc_url( WPBC_PLUGIN_URL . get_bk_option( 'booking_timeslot_picker_skin' ) ); ?>' );
459 - } );
460 - </script><?php
461 - $data_arr['calendar_force_load'] .= ob_get_clean();
462 - }
463 - $data_arr['calendar_force_load'] .= wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
464 - break;
465 -
466 - case 'cal_availability':
467 -
468 - $data_arr['calendar_force_load'] = wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
469 -
470 - // -----------------------------------------------------------------------------------------------------
471 - // == UNAVAILABLE WeekDays ==
472 - // -----------------------------------------------------------------------------------------------------
473 - $data_arr['ui']['booking_unavailable_day'] = array();
474 - for ( $wdi = 0; $wdi < 7; $wdi ++ ) {
475 - if ( get_bk_option( 'booking_unavailable_day' . $wdi ) == 'On' ) {
476 - $data_arr['ui']['booking_unavailable_day'][] = $wdi;
477 - }
478 - }
479 -
480 - /**
481 - * $unavailable_from_today_arr = [
482 - * booking_unavailable_days_num_from_today = "540m"
483 - * booking_unavailable_days_num_from_today__hint = ": 2025-01-25 15:19 - 2025-01-26 00:18:42"
484 - * booking_available_days_num_from_today = "0"
485 - * booking_available_days_num_from_today__hint = ": 26 Jan, 2025 - ..."
486 - * ]
487 - */
488 - $unavailable_from_today_arr = wpbc_get_unavailable_from_today_hints_arr();
489 -
490 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = $unavailable_from_today_arr['booking_unavailable_days_num_from_today'];
491 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = $unavailable_from_today_arr['booking_unavailable_days_num_from_today__hint'];
492 - $data_arr['ui']['booking_available_days_num_from_today'] = $unavailable_from_today_arr['booking_available_days_num_from_today'];
493 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = $unavailable_from_today_arr['booking_available_days_num_from_today__hint'];
494 -if(0){
495 - // -----------------------------------------------------------------------------------------------------
496 - // == UNAVAILABLE Today days ==
497 - // -----------------------------------------------------------------------------------------------------
498 - // FixIn: 10.8.1.4.
499 - $last_unavailable_date = '';
500 - if ( 'm' === substr( get_bk_option( 'booking_unavailable_days_num_from_today' ), - 1 ) ) {
501 - // -------------------------------------------------------------------------------------------------
502 - // == Minutes ==
503 - // -------------------------------------------------------------------------------------------------
504 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = intval( get_bk_option( 'booking_unavailable_days_num_from_today' ) );
505 -
506 - // Hints.
507 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': <span style="text-transform: lowercase;font-size:0.9em;">'
508 - . __( 'None', 'booking' ) . '</span>';
509 - if ( ! empty( $data_arr['ui']['booking_unavailable_days_num_from_today'] ) ) {
510 -
511 - $start_date_unix = strtotime( 'now' );
512 - $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' );
513 -
514 - $start_date_unix = strtotime( '+' . ( intval( $data_arr['ui']['booking_unavailable_days_num_from_today'] ) - 1 ) . ' minutes' );
515 - $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' );
516 -
517 - $last_unavailable_date = $max_date_with_wp_timezone;
518 -
519 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . $todate_with_wp_timezone . ' - ' . $max_date_with_wp_timezone; // FixIn: 10.9.4.2.
520 - }
521 - $data_arr['ui']['booking_unavailable_days_num_from_today'] .= 'm';
522 - } else {
523 - // -------------------------------------------------------------------------------------------------
524 - // == Days ==
525 - // -------------------------------------------------------------------------------------------------
526 - $data_arr['ui']['booking_unavailable_days_num_from_today'] = intval( get_bk_option( 'booking_unavailable_days_num_from_today' ) );
527 -
528 - // Hints.
529 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': <span style="text-transform: lowercase;font-size:0.9em;">' . __( 'None', 'booking' ) . '</span>';
530 -
531 - if ( 1 === $data_arr['ui']['booking_unavailable_days_num_from_today'] ) {
532 - $last_unavailable_date = wp_date( 'Y-m-d 00:00:00' );
533 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . wp_date( 'd M', strtotime( $last_unavailable_date ) );
534 - }
535 - if ( $data_arr['ui']['booking_unavailable_days_num_from_today'] > 1 ) {
536 - $last_unavailable_date = wp_date( 'Y-m-d 00:00:00', strtotime( '+' . ( $data_arr['ui']['booking_unavailable_days_num_from_today'] - 1 ) . ' days' ) );
537 - $data_arr['ui']['booking_unavailable_days_num_from_today__hint'] = ': ' . wp_date( 'd M' ) . ' - ' . wp_date( 'd M', strtotime( $last_unavailable_date ) );
538 - }
539 - }
540 -
541 - // -----------------------------------------------------------------------------------------------------
542 - // == AVAILABLE Today days ==
543 - // -----------------------------------------------------------------------------------------------------
544 - // if ( class_exists( 'wpdev_bk_biz_m' ) ) { .
545 - $data_arr['ui']['booking_available_days_num_from_today'] = esc_js( get_bk_option( 'booking_available_days_num_from_today' ) );
546 -
547 - // Hints.
548 - // $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 ) ) );
549 - if ( '' === $last_unavailable_date ) {
550 - $start_date_unix = strtotime( 'now' );
551 - $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' );
552 - $start_available_date = $todate_with_wp_timezone;
553 - } else {
554 - $start_available_date = $last_unavailable_date;
555 - // We use here with no WP timezone, because timezone already applied to $last_unavailable_date.
556 - $start_available_date = wpbc_datetime_localized__no_wp_timezone( strtotime( $last_unavailable_date ), 'Y-m-d 00:00:00' );
557 - }
558 -
559 -
560 - if ( empty( $data_arr['ui']['booking_available_days_num_from_today'] ) ) {
561 - $last_available_date = '';
562 - } else {
563 - // $last_available_date = wp_date( 'Y-m-d 00:00:00', strtotime( '+' . ( $data_arr['ui']['booking_available_days_num_from_today'] ) . ' days' ) );
564 - // FixIn: 10.9.6.3.
565 - $start_date_unix = strtotime( '+' . ( intval( $data_arr['ui']['booking_available_days_num_from_today'] ) - 1 ) . ' days' );
566 - $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' );
567 - }
568 -
569 - if ( ! empty( $data_arr['ui']['booking_available_days_num_from_today'] ) ) {
570 -
571 - if ( strtotime( $start_available_date ) < strtotime( $last_available_date ) ) {
572 -
573 - $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 ) );
574 - } else if ( strtotime( $start_available_date ) == strtotime( $last_available_date ) ) {
575 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) );
576 - } else {
577 - $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>' .
578 - ' <span style="text-transform: lowercase;font-size:0.9em;color:#cc3a5f;">' .
579 - 'Start available' . ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) ) . '<br>' .
580 - 'Last available' . ': ' . wp_date( 'd M, Y', strtotime( $last_available_date ) ) . '</span>';
581 - }
582 - } else {
583 - $data_arr['ui']['booking_available_days_num_from_today__hint'] = ': ' . wp_date( 'd M, Y', strtotime( $start_available_date ) ) . ' - ...';
584 - }
585 -}
586 -
587 - $data_arr['ui']['booking_unavailable_extra_in_out'] = get_bk_option( 'booking_unavailable_extra_in_out' );
588 - $data_arr['ui']['booking_unavailable_extra_minutes_in'] = get_bk_option( 'booking_unavailable_extra_minutes_in' );
589 - $data_arr['ui']['booking_unavailable_extra_minutes_out'] = get_bk_option( 'booking_unavailable_extra_minutes_out' );
590 - $data_arr['ui']['booking_unavailable_extra_days_in'] = get_bk_option( 'booking_unavailable_extra_days_in' );
591 - $data_arr['ui']['booking_unavailable_extra_days_out'] = get_bk_option( 'booking_unavailable_extra_days_out' );
592 -
593 - break;
594 -
595 - case 'color_theme':
596 -
597 - $data_arr['calendar_force_load'] = wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
598 - $data_arr['ui']['booking_form_theme'] = get_bk_option( 'booking_form_theme' );
599 - $data_arr['ui']['booking_skin'] = get_bk_option( 'booking_skin' );
600 - $data_arr['ui']['booking_timeslot_picker_skin'] = get_bk_option( 'booking_timeslot_picker_skin' );
601 - break;
602 -
603 - case 'optional_other_settings':
604 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
605 - break;
606 -
607 - case 'wizard_publish':
608 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
609 - break;
610 -
611 - case 'get_started':
612 - $data_arr['calendar_force_load'] = '';//wpbc_setup_wizard_page__get_shortcode_html( $cleaned_request_params['resource_id'] );
613 - break;
614 -
615 - default:
616 - $data_arr['calendar_force_load'] = '';
617 - }
618 -
619 -
620 413 // -------------------------------------------------------------------------------------------------------------
621 414 // Save Wizard history
622 415 // -------------------------------------------------------------------------------------------------------------
623 416 // Save to DB
@@ -626,49 +419,14 @@
626 419 // Ajax Transfer
627 420 $data_arr['booking_wizard_data'] = $booking_wizard_data_arr;
628 421 // -------------------------------------------------------------------------------------------------------------
629 422
630 -//TODO: delete this ?
631 -if(0){
632 -
633 - $data_arr['customize_steps'] = array();
634 - $data_arr['customize_steps']['action'] = 'none';
635 -
636 - // Actions =================================================================================================
637 -
638 - if ( 'save_calendar_additional' == $cleaned_request_params['do_action'] ) {
639 -
640 - $is_updated = update_bk_option( 'booking_max_monthes_in_calendar', $cleaned_request_params['calendar__booking_max_monthes_in_calendar'] );
641 - $is_updated = update_bk_option( 'booking_start_day_weeek', $cleaned_request_params['calendar__booking_start_day_weeek'] );
642 - }
643 -
644 - //----------------------------------------------------------------------------------------------------------
645 -
646 - // Get booking resources (sql)
647 - $resources_arr = wpbc_ajx_get_all_booking_resources_arr(); /**
648 - * Array ( [0] => Array ( [booking_type_id] => 1
649 - [title] => Standard
650 - [users] => 1
651 - [import] =>
652 - [export] =>
653 - [cost] => 25
654 - [default_form] => standard
655 - [prioritet] => 0
656 - [parent] => 0
657 - [visitors] => 2
658 - ), ... */
659 -
660 - $resources_arr_sorted = wpbc_ajx_get_sorted_booking_resources_arr( $resources_arr );
661 -
662 - $data_arr['ajx_booking_resources'] = $resources_arr_sorted;
663 -}
664 -
665 -
666 423 // -------------------------------------------------------------------------------------------------------------
667 424 // Save Status of Wizard for specific user
668 425 // -------------------------------------------------------------------------------------------------------------
669 426 if ( 'make_reset' !== $cleaned_request_params['do_action'] ) {
670 427
428 + $cleaned_request_params['current_step'] = $data_arr['current_step'];
671 429 $request_params_to_save = $cleaned_request_params;
672 430
673 431 // Do not safe such elements
674 432 unset( $request_params_to_save['ui_clicked_element_id'] );
@@ -698,7 +456,7 @@
698 456 /**
699 457 * Just for loading CSS and JavaScript files
700 458 */
701 459 if ( true ) {
702 - $setup_wizard_page_loading = new WPBC_AJX__Setup_Wizard__Ajax_Request;
703 - $setup_wizard_page_loading->define_ajax_hook();
704 -}
460 + $wpbc_setup_wizard_page_loading = new WPBC_AJX__Setup_Wizard__Ajax_Request;
461 + $wpbc_setup_wizard_page_loading->define_ajax_hook();
462 +}