| 1 |
<?php /** |
| 2 |
* @version 1.0 |
| 3 |
* @description Ajax and Requests Structure for WPBC_AJX__Setup__Ajax_Request |
| 4 |
* @category Setup Class |
| 5 |
* @author wpdevelop |
| 6 |
* |
| 7 |
* @web-site http://oplugins.com/ |
| 8 |
* @email info@oplugins.com |
| 9 |
* |
| 10 |
* @modified 2023-06-23 |
| 11 |
*/ |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 14 |
|
| 15 |
// ===================================================================================================================== |
| 16 |
// == Get RULES STRUCTURE == |
| 17 |
// ===================================================================================================================== |
| 18 |
|
| 19 |
/** |
| 20 |
* Get params names for escaping and/or default value of such params |
| 21 |
* |
| 22 |
* @return array array ( 'resource_id' => array( 'validate' => 'digit_or_csd', 'default' => array( '1' ) ) |
| 23 |
* , ... ) |
| 24 |
*/ |
| 25 |
function wpbc_setup_wizard_page__request_rules_structure() { |
| 26 |
|
| 27 |
return array( |
| 28 |
'do_action' => array( |
| 29 |
'validate' => array( |
| 30 |
'none', |
| 31 |
'save_and_continue', |
| 32 |
'make_reset', 'skip_wizard', |
| 33 |
|
| 34 |
'save_and_continue__welcome', |
| 35 |
'save_and_continue__general_info', |
| 36 |
'save_and_continue__date_time_formats', |
| 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' |
| 45 |
), |
| 46 |
'default' => 'none' |
| 47 |
), |
| 48 |
'current_step' => array( 'validate' => 's', 'default' => '' ), |
| 49 |
'resource_id' => array( 'validate' => 'd', 'default' => wpbc_get_default_resource() ), |
| 50 |
'ui_clicked_element_id' => array( 'validate' => 's', 'default' => '' ) |
| 51 |
// 'calendar__booking_start_day_weeek' => array( 'validate' => array( '0', '1', '2', '3', '4', '5', '6' ), 'default' => get_bk_option( 'booking_start_day_weeek' ) ) |
| 52 |
); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* Get default params |
| 58 |
* |
| 59 |
* @return array array ( 'ui_wh_modification_date_radio' => 0 |
| 60 |
* , ... ) |
| 61 |
*/ |
| 62 |
function wpbc_setup_wizard_page__get__request_values__default(){ |
| 63 |
|
| 64 |
$request_rules_structure = wpbc_setup_wizard_page__request_rules_structure(); |
| 65 |
|
| 66 |
$default_params_arr = array(); |
| 67 |
|
| 68 |
$structure_type = 'default'; |
| 69 |
|
| 70 |
foreach ( $request_rules_structure as $key => $value ) { |
| 71 |
$default_params_arr[ $key ] = $value[ $structure_type ]; |
| 72 |
} |
| 73 |
|
| 74 |
return $default_params_arr; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
// ===================================================================================================================== |
| 79 |
// == Get sanitised Request parameters for Ajax == |
| 80 |
// ===================================================================================================================== |
| 81 |
|
| 82 |
/** |
| 83 |
* Get sanitised request parameters. | 01. -> Firstly check if user saved request params in user_meta DB. |
| 84 |
* | 02. -> Otherwise check $_REQUEST. |
| 85 |
* | 03. -> Otherwise Get default. |
| 86 |
* |
| 87 |
* @return array|false |
| 88 |
*/ |
| 89 |
function wpbc_setup_wizard_page__get_cleaned_params__saved_request_default(){ |
| 90 |
|
| 91 |
// User Specific Experience with Setup -> saved to user meta_table. |
| 92 |
// E.g. next time user open the page with saved own settings |
| 93 |
$user_request = new WPBC_AJX__REQUEST( array( |
| 94 |
'db_option_name' => 'booking_setup_wizard_page_request_params', |
| 95 |
'user_id' => wpbc_get_current_user_id(), |
| 96 |
'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure() |
| 97 |
) |
| 98 |
); |
| 99 |
|
| 100 |
// ----------------------------------------------------------------------------------------------------------------- |
| 101 |
// Get saved from DB |
| 102 |
// ----------------------------------------------------------------------------------------------------------------- |
| 103 |
$escaped_request_params_arr = $user_request->get_sanitized__saved__user_request_params(); |
| 104 |
|
| 105 |
|
| 106 |
// ----------------------------------------------------------------------------------------------------------------- |
| 107 |
// Get $_REQUEST or Default :: This request was not saved before, then get sanitized direct parameters , such as: $_REQUEST['resource_id'] |
| 108 |
// ----------------------------------------------------------------------------------------------------------------- |
| 109 |
if ( false === $escaped_request_params_arr ) { |
| 110 |
$request_prefix = false; |
| 111 |
$escaped_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); |
| 112 |
} |
| 113 |
|
| 114 |
// ----------------------------------------------------------------------------------------------------------------- |
| 115 |
// == O V E R R I D E - DB params by the params from REQUEST! == |
| 116 |
// ----------------------------------------------------------------------------------------------------------------- |
| 117 |
$request_key = 'current_step'; |
| 118 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 119 |
if ( isset( $_REQUEST[ $request_key ] ) ) { |
| 120 |
|
| 121 |
// Get SANITIZED REQUEST parameters together with default values |
| 122 |
$request_prefix = false; |
| 123 |
$url_request_params_arr = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // Direct: $_REQUEST['resource_id'] |
| 124 |
|
| 125 |
// Now get only SANITIZED values that exist in REQUEST |
| 126 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 127 |
$url_request_params_only_arr = array_intersect_key( $url_request_params_arr, $_REQUEST ); |
| 128 |
|
| 129 |
// And now override our DB $escaped_request_params_arr by SANITIZED $_REQUEST values |
| 130 |
$escaped_request_params_arr = wp_parse_args( $url_request_params_only_arr, $escaped_request_params_arr ); |
| 131 |
} |
| 132 |
// --------------------------------------------------------------------------------------------------------- |
| 133 |
|
| 134 |
// //MU |
| 135 |
// if ( class_exists( 'wpdev_bk_multiuser' ) ) { |
| 136 |
// |
| 137 |
// // Check if this MU user activated or super-admin, otherwise show warning |
| 138 |
// if ( ! wpbc_is_mu_user_can_be_here('activated_user') ) |
| 139 |
// return false; |
| 140 |
// |
| 141 |
// // Check if this MU user owner of this resource or super-admin, otherwise show warning |
| 142 |
// if ( ! wpbc_is_mu_user_can_be_here( 'resource_owner', $escaped_request_params_arr['resource_id'] ) ) { |
| 143 |
// $default_values = $user_request->get_request_rules__default(); |
| 144 |
// $escaped_request_params_arr['resource_id'] = $default_values['resource_id']; |
| 145 |
// } |
| 146 |
// } |
| 147 |
|
| 148 |
return $escaped_request_params_arr; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
// ===================================================================================================================== |
| 153 |
// == A J A X == |
| 154 |
// ===================================================================================================================== |
| 155 |
|
| 156 |
class WPBC_AJX__Setup_Wizard__Ajax_Request { |
| 157 |
|
| 158 |
|
| 159 |
/** |
| 160 |
* Define HOOKs for start loading Ajax |
| 161 |
*/ |
| 162 |
public function define_ajax_hook(){ |
| 163 |
|
| 164 |
// Ajax Handlers. Note. "locale_for_ajax" rechecked in wpbc-ajax.php |
| 165 |
add_action( 'wp_ajax_' . 'WPBC_AJX_SETUP_WIZARD_PAGE', array( $this, 'ajax_' . 'WPBC_AJX_SETUP_WIZARD_PAGE' ) ); // Admin & Client (logged in usres) |
| 166 |
|
| 167 |
// Ajax Handlers for actions |
| 168 |
// add_action( 'wp_ajax_nopriv_' . 'WPBC_AJX_BOOKING_LISTING', array( $this, 'ajax_' . 'WPBC_AJX_BOOKING_LISTING' ) ); // Client (not logged in) |
| 169 |
} |
| 170 |
|
| 171 |
|
| 172 |
/** |
| 173 |
* Ajax - Get Listing Data and Response to JS script |
| 174 |
*/ |
| 175 |
public function ajax_WPBC_AJX_SETUP_WIZARD_PAGE() { |
| 176 |
|
| 177 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 178 |
if ( ! isset( $_POST['all_ajx_params'] ) || empty( $_POST['all_ajx_params'] ) ) { exit; } |
| 179 |
|
| 180 |
// ------------------------------------------------------------------------------------------------------------- |
| 181 |
// == Security == -> in Ajax Post: 'nonce': wpbc_ajx_booking_listing.get_secure_param( 'nonce' ) |
| 182 |
// ------------------------------------------------------------------------------------------------------------- |
| 183 |
$action_name = 'wpbc_setup_wizard_page_ajx' . '_wpbcnonce'; |
| 184 |
$nonce_post_key = 'nonce'; |
| 185 |
$result_check = check_ajax_referer( $action_name, $nonce_post_key ); |
| 186 |
|
| 187 |
$user_id = ( isset( $_REQUEST['wpbc_ajx_user_id'] ) ) ? intval( $_REQUEST['wpbc_ajx_user_id'] ) : wpbc_get_current_user_id(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 188 |
|
| 189 |
// ------------------------------------------------------------------------------------------------------------- |
| 190 |
// == Request == -> $_REQUEST['all_ajx_params']['page_num'], $_REQUEST['all_ajx_params']['page_items_count'], ... |
| 191 |
// ------------------------------------------------------------------------------------------------------------- |
| 192 |
$user_request = new WPBC_AJX__REQUEST( array( |
| 193 |
'db_option_name' => 'booking_setup_wizard_page_request_params', |
| 194 |
'user_id' => $user_id, |
| 195 |
'request_rules_structure' => wpbc_setup_wizard_page__request_rules_structure() |
| 196 |
) |
| 197 |
); |
| 198 |
//-------------------------------------------------------------------------------------------------------------- |
| 199 |
// If in Ajax: all_ajx_params: _wpbc_settings.get_all_..() -> Use prefix "all_ajx_params" THEN Sanitize required REQUEST params |
| 200 |
//-------------------------------------------------------------------------------------------------------------- |
| 201 |
$request_prefix = 'all_ajx_params'; |
| 202 |
$cleaned_request_params = $user_request->get_sanitized__in_request__value_or_default( $request_prefix ); // NOT Direct: $_REQUEST['all_ajx_params']['resource_id'] |
| 203 |
//-------------------------------------------------------------------------------------------------------------- |
| 204 |
|
| 205 |
$cleaned_data = array(); |
| 206 |
$setup_steps = new WPBC_SETUP_WIZARD_STEPS(); |
| 207 |
|
| 208 |
$data_arr = array(); |
| 209 |
$data_arr['ajx_after_action_message'] = ''; |
| 210 |
$data_arr['ajx_after_action_result'] = 1; // Message Type: ? '1' => 'success' : 'error' |
| 211 |
//-------------------------------------------------------------------------------------------------------------- |
| 212 |
// Steps |
| 213 |
//-------------------------------------------------------------------------------------------------------------- |
| 214 |
$data_arr['current_step'] = ( ! empty( $cleaned_request_params['current_step'] ) |
| 215 |
? $cleaned_request_params['current_step'] |
| 216 |
: $setup_steps->get_active_step_name() ); // e.g. 'general_info' or 'optional_other_settings' |
| 217 |
$data_arr['steps'] = $setup_steps->get_steps_arr(); |
| 218 |
|
| 219 |
// ------------------------------------------------------------------------------------------------------------- |
| 220 |
// Get Wizard history |
| 221 |
// ------------------------------------------------------------------------------------------------------------- |
| 222 |
$booking_wizard_data_arr = get_bk_option( 'booking_wizard_data' ); |
| 223 |
$booking_wizard_data_arr = ( empty( $booking_wizard_data_arr ) ) ? array() : $booking_wizard_data_arr; |
| 224 |
|
| 225 |
|
| 226 |
// ============================================================================================================= |
| 227 |
// == Do Action == |
| 228 |
// ============================================================================================================= |
| 229 |
switch ( $cleaned_request_params['do_action'] ) { |
| 230 |
|
| 231 |
// --------------------------------------------------------------------------------------------------------- |
| 232 |
// == RESET == |
| 233 |
// --------------------------------------------------------------------------------------------------------- |
| 234 |
case 'make_reset': |
| 235 |
|
| 236 |
$is_reseted = $user_request->user_request_params__db_delete(); // Delete from DB |
| 237 |
|
| 238 |
$cleaned_request_params['do_action'] = $is_reseted ? 'reset_done' : 'reset_error'; |
| 239 |
|
| 240 |
$cleaned_request_params = wpbc_setup_wizard_page__get__request_values__default(); |
| 241 |
|
| 242 |
$data_arr['ajx_after_action_message'] = __( 'Start Setup from Beginning', 'booking' ); |
| 243 |
|
| 244 |
$data_arr['current_step'] = 'welcome'; |
| 245 |
|
| 246 |
update_bk_option( 'booking_wizard_data', array() ); |
| 247 |
|
| 248 |
$setup_steps->db__set_all_steps_as( false ); // Clear All Steps Mark as Undone |
| 249 |
break; |
| 250 |
|
| 251 |
case 'skip_wizard': |
| 252 |
|
| 253 |
$data_arr['current_step'] = 'welcome'; |
| 254 |
$data_arr['redirect_url'] = wpbc_get_settings_url(); |
| 255 |
|
| 256 |
$setup_steps->db__set_all_steps_as( true ); // Mark All Steps as Done |
| 257 |
|
| 258 |
break; |
| 259 |
|
| 260 |
case 'save_and_continue__welcome': |
| 261 |
|
| 262 |
$setup_steps->db__set_step_as_completed( 'welcome' ); |
| 263 |
break; |
| 264 |
|
| 265 |
case 'save_and_continue__general_info': |
| 266 |
|
| 267 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 268 |
if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) { |
| 269 |
$cleaned_data = wpbc_template__general_info__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 |
| 270 |
|
| 271 |
if ( 'On' === $cleaned_data['wpbc_swp_accept_send'] ) { |
| 272 |
//wpbc_setup_feedback__send_email( $cleaned_data ); // FixIn: 10.7.1.3. |
| 273 |
update_bk_option( 'booking_feedback__send_email', $cleaned_data ); |
| 274 |
} else { |
| 275 |
delete_bk_option( 'booking_feedback__send_email' ); |
| 276 |
} |
| 277 |
|
| 278 |
wpbc_setup__update__general_info( $cleaned_data ); |
| 279 |
} |
| 280 |
|
| 281 |
$setup_steps->db__set_step_as_completed( 'general_info' ); |
| 282 |
break; |
| 283 |
|
| 284 |
case 'save_and_continue__date_time_formats': |
| 285 |
|
| 286 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 287 |
if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) { |
| 288 |
$cleaned_data = wpbc_template__date_time_formats__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 |
| 289 |
wpbc_setup__update__date_time_formats( $cleaned_data ); |
| 290 |
} |
| 291 |
|
| 292 |
$setup_steps->db__set_step_as_completed( 'date_time_formats' ); |
| 293 |
break; |
| 294 |
|
| 295 |
case 'save_and_continue__bookings_types': |
| 296 |
|
| 297 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 298 |
if ( isset( $_POST['all_ajx_params']['step_data'] ) && ( ! empty( $_POST['all_ajx_params']['step_data'] ) ) ) { |
| 299 |
$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 |
| 300 |
wpbc_setup__update__bookings_types( $cleaned_data ); |
| 301 |
|
| 302 |
// FixIn: 10.7.1.3. |
| 303 |
$cleaned_data_booking_feedback_arr = get_bk_option( 'booking_feedback__send_email' ); |
| 304 |
if (! empty($cleaned_data_booking_feedback_arr)){ |
| 305 |
if ( 'On' === $cleaned_data_booking_feedback_arr['wpbc_swp_accept_send'] ) { |
| 306 |
$cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr , array( 'type' => 'Type: ' . $cleaned_data ['wpbc_swp_booking_types'] ) ); |
| 307 |
if ( 'time_slots_appointments' === $cleaned_data ['wpbc_swp_booking_types'] ) { |
| 308 |
$cleaned_data_booking_feedback_arr = array_merge( $cleaned_data_booking_feedback_arr, array( 'appointments_type' => 'Appointment: ' . $cleaned_data ['wpbc_swp_booking_appointments_type'] ) ); |
| 309 |
} |
| 310 |
wpbc_setup_feedback__send_email( $cleaned_data_booking_feedback_arr ); |
| 311 |
delete_bk_option( 'booking_feedback__send_email' ); |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 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 |
} |
| 336 |
|
| 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 ); |
| 346 |
} |
| 347 |
|
| 348 |
$setup_steps->db__set_step_as_completed( 'form_structure' ); |
| 349 |
break; |
| 350 |
|
| 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 |
default: |
| 431 |
// Default |
| 432 |
} |
| 433 |
|
| 434 |
//-------------------------------------------------------------------------------------------------------------- |
| 435 |
// Other |
| 436 |
//-------------------------------------------------------------------------------------------------------------- |
| 437 |
$data_arr['steps_is_done'] = $setup_steps->db__get_steps_is_done(); |
| 438 |
$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(); |
| 440 |
|
| 441 |
//-------------------------------------------------------------------------------------------------------------- |
| 442 |
// Load Calendar depend on Step |
| 443 |
//-------------------------------------------------------------------------------------------------------------- |
| 444 |
$data_arr['ui'] = array(); |
| 445 |
|
| 446 |
switch ( $data_arr['current_step'] ) { |
| 447 |
|
| 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 |
// ------------------------------------------------------------------------------------------------------------- |
| 621 |
// Save Wizard history |
| 622 |
// ------------------------------------------------------------------------------------------------------------- |
| 623 |
// Save to DB |
| 624 |
$booking_wizard_data_arr[ $cleaned_request_params['do_action'] ] = $cleaned_data; |
| 625 |
update_bk_option( 'booking_wizard_data', $booking_wizard_data_arr ); |
| 626 |
// Ajax Transfer |
| 627 |
$data_arr['booking_wizard_data'] = $booking_wizard_data_arr; |
| 628 |
// ------------------------------------------------------------------------------------------------------------- |
| 629 |
|
| 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 |
// ------------------------------------------------------------------------------------------------------------- |
| 667 |
// Save Status of Wizard for specific user |
| 668 |
// ------------------------------------------------------------------------------------------------------------- |
| 669 |
if ( 'make_reset' !== $cleaned_request_params['do_action'] ) { |
| 670 |
|
| 671 |
$request_params_to_save = $cleaned_request_params; |
| 672 |
|
| 673 |
// Do not safe such elements |
| 674 |
unset( $request_params_to_save['ui_clicked_element_id'] ); |
| 675 |
unset( $request_params_to_save['do_action'] ); |
| 676 |
unset( $request_params_to_save['calendar_force_load'] ); |
| 677 |
unset( $request_params_to_save['plugin_menu__setup_progress'] ); |
| 678 |
|
| 679 |
$is_success_update = $user_request->user_request_params__db_save( $request_params_to_save ); // Save to DB // - $cleaned_request_params - serialized here automatically |
| 680 |
} |
| 681 |
|
| 682 |
if ( ! empty( $data_arr['calendar_force_load'] ) ) { |
| 683 |
$data_arr['calendar_force_load'] = wpbc_clean_calendar_loading_scripts( $data_arr['calendar_force_load'] ); |
| 684 |
} |
| 685 |
// ------------------------------------------------------------------------------------------------------------- |
| 686 |
// Send JSON. It will make "wp_json_encode" - so pass only array, and This function call wp_die( '', '', array( 'response' => null, ) ) Pass JS OBJ: response_data in "jQuery.post( " function on success. |
| 687 |
// ------------------------------------------------------------------------------------------------------------- |
| 688 |
wp_send_json( array( |
| 689 |
'ajx_data' => $data_arr, |
| 690 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 691 |
'ajx_all_ajx_params' => $_REQUEST[ $request_prefix ], // $_REQUEST[ 'all_ajx_params' ] |
| 692 |
'ajx_cleaned_params' => $cleaned_request_params |
| 693 |
) ); |
| 694 |
} |
| 695 |
|
| 696 |
} |
| 697 |
|
| 698 |
/** |
| 699 |
* Just for loading CSS and JavaScript files |
| 700 |
*/ |
| 701 |
if ( true ) { |
| 702 |
$setup_wizard_page_loading = new WPBC_AJX__Setup_Wizard__Ajax_Request; |
| 703 |
$setup_wizard_page_loading->define_ajax_hook(); |
| 704 |
} |