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