| 1 |
<?php |
| 2 |
/** |
| 3 |
* AJAX save handler for General Availability. |
| 4 |
* |
| 5 |
* @package Booking Calendar |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* AJAX: save General Availability settings. |
| 14 |
* |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
function wpbc_availability_general_ajax_save() { |
| 18 |
|
| 19 |
$nonce_result = check_ajax_referer( 'wpbc_availability_general_ajax_nonce', 'nonce', false ); |
| 20 |
if ( false === $nonce_result ) { |
| 21 |
wp_send_json_error( array( 'message' => __( 'Security check failed.', 'booking' ) ), 403 ); |
| 22 |
} |
| 23 |
|
| 24 |
if ( ! wpbc_is_mu_user_can_be_here( 'only_super_admin' ) || ! current_user_can( wpbc_availability_general__get_manage_cap() ) ) { |
| 25 |
wp_send_json_error( array( 'message' => __( 'You do not have permission to change general availability.', 'booking' ) ), 403 ); |
| 26 |
} |
| 27 |
|
| 28 |
$cleaned_data = wpbc_availability_general__validate_data( $_POST ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing |
| 29 |
wpbc_availability_general__update_settings( $cleaned_data ); |
| 30 |
|
| 31 |
wp_send_json_success( |
| 32 |
array( |
| 33 |
'message' => __( 'General availability settings updated.', 'booking' ), |
| 34 |
'settings' => wpbc_availability_general__get_settings_response(), |
| 35 |
) |
| 36 |
); |
| 37 |
} |
| 38 |
add_action( 'wp_ajax_WPBC_AJX_AVAILABILITY_GENERAL_SAVE', 'wpbc_availability_general_ajax_save' ); |
| 39 |
|