| 1 |
<?php |
| 2 |
/** |
| 3 |
* @version 1.0 |
| 4 |
* @package Booking Calendar |
| 5 |
* @subpackage Ajax Responder |
| 6 |
* @category Bookings |
| 7 |
* |
| 8 |
* @author wpdevelop |
| 9 |
* @link https://wpbookingcalendar.com/ |
| 10 |
* @email info@wpbookingcalendar.com |
| 11 |
* |
| 12 |
* @modified 2014.05.26 |
| 13 |
*/ |
| 14 |
|
| 15 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
// --------------------------------------------------------------------------------------------------------------------- |
| 20 |
// A j a x H o o k s f o r s p e c i f i c A c t i o n s ///// |
| 21 |
// --------------------------------------------------------------------------------------------------------------------- |
| 22 |
|
| 23 |
|
| 24 |
//FixIn: Flex TimeLine 1.0 |
| 25 |
function wpbc_ajax_WPBC_FLEXTIMELINE_NAV() { |
| 26 |
|
| 27 |
// if ( ! wpbc_check_nonce_in_admin_panel( $_POST['action'] ) ) return false; //FixIn: 7.2.1.10 // This line for admin panel |
| 28 |
|
| 29 |
if ( wpbc_is_use_nonce_at_front_end() ) { // FixIn: 10.1.1.2. |
| 30 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 31 |
$nonce = ( isset( $_REQUEST['wpbc_nonce'] ) ) ? $_REQUEST['wpbc_nonce'] : ''; |
| 32 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 33 |
if ( ! wp_verify_nonce( $nonce, $_POST['action'] ) ) { // This nonce is not valid. |
| 34 |
/* translators: 1: ... */ |
| 35 |
wp_die( wp_kses_post( sprintf( __( '%1$sError!%2$s Request do not pass security check! Please refresh the page and try one more time.', 'booking' ), '<strong>', '</strong>' ) . '<br/>' . sprintf( __( 'Please check more %1$shere%2$s', 'booking' ), '<a href="https://wpbookingcalendar.com/faq/request-do-not-pass-security-check/?after_update=10.1.1" target="_blank">', '</a>.' ) // FixIn: 8.8.3.6. |
| 36 |
) ); // Its prevent of showing '0' et the end of request. |
| 37 |
} |
| 38 |
} |
| 39 |
make_bk_action( 'wpbc_ajax_flex_timeline' ); |
| 40 |
wp_die( '' ); // Its prevent of showing '0' et the end of request. |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
function wpbc_ajax_CALCULATE_THE_COST() { |
| 45 |
|
| 46 |
if ( wpbc_is_use_nonce_at_front_end() ) { // FixIn: 10.1.1.2. |
| 47 |
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 48 |
if ( ! wpbc_check_nonce_in_admin_panel( $_POST['action'] ) ) { |
| 49 |
return false;// FixIn: 7.2.1.10. |
| 50 |
} |
| 51 |
} |
| 52 |
make_bk_action( 'wpdev_ajax_show_cost' ); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
// FixIn: 9.6.3.5. |
| 58 |
|
| 59 |
function wpbc_ajax_UPDATE_APPROVE() { |
| 60 |
|
| 61 |
global $wpdb; |
| 62 |
|
| 63 |
if ( ! wpbc_check_nonce_in_admin_panel() ) { |
| 64 |
return false; // FixIn: 7.2.1.10. |
| 65 |
} |
| 66 |
|
| 67 |
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 68 |
make_bk_action( 'check_multiuser_params_for_client_side_by_user_id', sanitize_text_field( wp_unslash( $_POST['user_id'] ) ) ); |
| 69 |
|
| 70 |
// Approve or Reject? |
| 71 |
// phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated |
| 72 |
$is_approve_or_pending = ( 1 == $_POST["is_approve_or_pending"] ) ? '1' : '0'; |
| 73 |
|
| 74 |
$booking_id = isset( $_POST['booking_id'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_id'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ // Booking ID. |
| 75 |
|
| 76 |
$approved_id = explode( '|', $booking_id ); |
| 77 |
$approved_id = wpbc_clean_digit_or_csd( $approved_id ); // FixIn: 8.4.5.15. |
| 78 |
|
| 79 |
$denyreason = isset( $_POST['denyreason'] ) ? sanitize_textarea_field( wp_unslash( $_POST['denyreason'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 80 |
$is_send_emeils = isset( $_POST['is_send_emeils'] ) ? sanitize_text_field( wp_unslash( $_POST['is_send_emeils'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 81 |
|
| 82 |
if ( ( count( $approved_id ) > 0 ) && ( false !== $approved_id ) ) { |
| 83 |
|
| 84 |
$approved_id_str = join( ',', $approved_id ); |
| 85 |
$approved_id_str = wpbc_clean_digit_or_csd( $approved_id_str ); |
| 86 |
|
| 87 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 88 |
if ( false === $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->prefix}bookingdates SET approved = %s WHERE booking_id IN ( {$approved_id_str} )", $is_approve_or_pending ) ) ) { |
| 89 |
?> |
| 90 |
<script type="text/javascript"> |
| 91 |
var my_message = '<?php echo esc_js( get_debuge_error( 'Error during updating to DB', __FILE__, __LINE__ ) ); ?>'; |
| 92 |
wpbc_admin_show_message(my_message, 'error', 30000); |
| 93 |
</script> |
| 94 |
<?php |
| 95 |
die(); |
| 96 |
} |
| 97 |
|
| 98 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 99 |
$curr_user = get_user_by( 'id', $my_user_id ); |
| 100 |
$user_info = $curr_user->first_name . ' ' . $curr_user->last_name . ' (' . $curr_user->user_email . ')'; // get_user_meta( $curr_user->ID, 'nickname' ). |
| 101 |
wpbc_db__add_log_info( explode(',',$approved_id_str), |
| 102 |
( ( $is_approve_or_pending == '1' ) ? __( 'Approved by:', 'booking' ) : __( 'Declined by:', 'booking' ) ) |
| 103 |
. ' ' . $user_info ); |
| 104 |
|
| 105 |
wpbc_db_update_number_new_bookings( explode(',', $approved_id_str) ); |
| 106 |
|
| 107 |
do_action( 'wpbc_booking_approved', $approved_id_str, $is_approve_or_pending ); // FixIn: 8.7.6.1. |
| 108 |
|
| 109 |
if ( $is_approve_or_pending == '1' ) { |
| 110 |
if ( ! empty( $is_send_emeils ) ) // FixIn: 7.0.1.5. |
| 111 |
{ |
| 112 |
wpbc_send_email_approved( $approved_id_str, $is_send_emeils, $denyreason ); |
| 113 |
} |
| 114 |
$all_bk_id_what_canceled = apply_bk_filter( 'cancel_pending_same_resource_bookings_for_specific_dates', false, $approved_id_str ); |
| 115 |
} else { |
| 116 |
if ( ! empty( $is_send_emeils ) ) { |
| 117 |
wpbc_send_email_deny( $approved_id_str, $is_send_emeils, $denyreason ); |
| 118 |
} |
| 119 |
} |
| 120 |
|
| 121 |
?> |
| 122 |
<script type="text/javascript"> |
| 123 |
<?php |
| 124 |
foreach ( $approved_id as $bk_id ) { |
| 125 |
if ( $is_approve_or_pending == '1' ) { |
| 126 |
?> |
| 127 |
set_booking_row_approved_in_timeline(<?php echo esc_attr( $bk_id ); ?>); |
| 128 |
set_booking_row_approved(<?php echo esc_attr( $bk_id ); ?>); |
| 129 |
set_booking_row_read(<?php echo esc_attr( $bk_id ); ?>); |
| 130 |
<?php |
| 131 |
} else { |
| 132 |
?> |
| 133 |
set_booking_row_pending_in_timeline(<?php echo esc_attr( $bk_id ); ?>); |
| 134 |
set_booking_row_pending(<?php echo esc_attr( $bk_id ); ?>); |
| 135 |
<?php |
| 136 |
} |
| 137 |
} |
| 138 |
?> |
| 139 |
<?php if ($is_approve_or_pending == '1') { ?> |
| 140 |
var my_message = '<?php echo esc_js( __( 'Set as Approved', 'booking' ) ); ?>'; |
| 141 |
<?php } else { ?> |
| 142 |
var my_message = '<?php echo esc_js( __( 'Set as Pending', 'booking' ) ); ?>'; |
| 143 |
<?php } ?> |
| 144 |
wpbc_admin_show_message(my_message, 'success', 3000); |
| 145 |
</script> |
| 146 |
<?php |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
//FixIn: 6.1.1.10 |
| 152 |
function wpbc_ajax_TRASH_RESTORE() { |
| 153 |
global $wpdb; |
| 154 |
|
| 155 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 156 |
|
| 157 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 158 |
make_bk_action('check_multiuser_params_for_client_side_by_user_id', $my_user_id ); |
| 159 |
|
| 160 |
$booking_id = isset( $_POST['booking_id'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_id'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ // Booking ID. |
| 161 |
|
| 162 |
$denyreason = isset( $_POST['denyreason'] ) ? sanitize_textarea_field( wp_unslash( $_POST['denyreason'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 163 |
|
| 164 |
if ( ( $denyreason === __( 'Reason for cancellation here', 'booking' ) ) || ( $denyreason === __( 'Reason of cancellation here', 'booking' ) ) || ( $denyreason === 'Reason of cancel here' ) ) { |
| 165 |
$denyreason = ''; |
| 166 |
} |
| 167 |
|
| 168 |
$is_send_emeils = isset( $_POST['is_send_emeils'] ) ? sanitize_text_field( wp_unslash( $_POST['is_send_emeils'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 169 |
|
| 170 |
$approved_id = explode( '|', $booking_id ); |
| 171 |
$approved_id = wpbc_clean_digit_or_csd( $approved_id ); // FixIn: 8.4.5.15. |
| 172 |
|
| 173 |
$is_trash = isset( $_POST['is_trash'] ) ? intval( $_POST['is_trash'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 174 |
|
| 175 |
if ( ( count( $approved_id ) > 0 ) && ( $approved_id != false ) && ( $approved_id != '' ) ) { |
| 176 |
|
| 177 |
$approved_id_str = join( ',', $approved_id); |
| 178 |
$approved_id_str = wpbc_clean_like_string_for_db( $approved_id_str ); |
| 179 |
|
| 180 |
do_action( 'wpbc_booking_trash', $booking_id, $is_trash ); // FixIn: .8.7.6.2. |
| 181 |
|
| 182 |
if ( $is_trash ) { |
| 183 |
if ( ! empty( $is_send_emeils ) ) { // FixIn: 8.1.3.35. |
| 184 |
wpbc_send_email_trash( $approved_id_str, $is_send_emeils, $denyreason ); |
| 185 |
} |
| 186 |
} else { |
| 187 |
if ( ! empty( $is_send_emeils ) ) { // FixIn: 8.1.3.35. |
| 188 |
// wpbc_send_email_approved($approved_id_str, $is_send_emeils,$denyreason); // FixIn: 8.1.2.7. |
| 189 |
} |
| 190 |
} |
| 191 |
// FixIn: 10.12.1.5. |
| 192 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 193 |
if ( false === $wpdb->query( "UPDATE {$wpdb->prefix}booking SET trash = {$is_trash} WHERE booking_id IN ({$approved_id_str})" ) ) { |
| 194 |
?> |
| 195 |
<script type="text/javascript"> |
| 196 |
var my_message = '<?php echo esc_attr( html_entity_decode( esc_js( get_debuge_error( 'Error during trash booking in DB', __FILE__, __LINE__ ) ), ENT_QUOTES ) ); ?>'; |
| 197 |
wpbc_admin_show_message(my_message, 'error', 30000); |
| 198 |
</script> |
| 199 |
<?php |
| 200 |
die(); |
| 201 |
} |
| 202 |
|
| 203 |
// Update the Hash and Cost of the booking |
| 204 |
$booking_id_arr = explode( ',', $approved_id_str ); // FixIn: 8.6.1.11. |
| 205 |
foreach ( $booking_id_arr as $booking_id ) { |
| 206 |
wpbc_hash__update_booking_hash( $booking_id ); |
| 207 |
} |
| 208 |
|
| 209 |
?> <script type="text/javascript"> |
| 210 |
<?php |
| 211 |
|
| 212 |
if ( $is_trash ) { |
| 213 |
|
| 214 |
foreach ($approved_id as $bk_id) { |
| 215 |
?> |
| 216 |
set_booking_row_trash(<?php echo esc_attr( $bk_id ); ?>); |
| 217 |
//set_booking_row_deleted_in_timeline(<?php echo esc_attr( $bk_id ); ?>); |
| 218 |
//setTimeout(function() { set_booking_row_deleted(<?php echo esc_attr( $bk_id ); ?>); }, 1000); |
| 219 |
<?php |
| 220 |
} |
| 221 |
?> |
| 222 |
var my_message = '<?php echo esc_js( __('Moved to trash' ,'booking') ) ; ?>'; |
| 223 |
wpbc_admin_show_message( my_message, 'success', 3000 ); |
| 224 |
<?php |
| 225 |
} else { |
| 226 |
foreach ($approved_id as $bk_id) { |
| 227 |
?> set_booking_row_restore(<?php echo esc_attr( $bk_id ); ?>); <?php |
| 228 |
} |
| 229 |
?> |
| 230 |
var my_message = '<?php echo esc_js( __('Restored' ,'booking') ) ; ?>'; |
| 231 |
wpbc_admin_show_message( my_message, 'success', 3000 ); |
| 232 |
<?php |
| 233 |
} |
| 234 |
?> |
| 235 |
</script> |
| 236 |
<?php |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
// FixIn: 9.6.3.5. |
| 241 |
|
| 242 |
|
| 243 |
function wpbc_ajax_DELETE_APPROVE() { |
| 244 |
|
| 245 |
global $wpdb; |
| 246 |
|
| 247 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 248 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 249 |
make_bk_action('check_multiuser_params_for_client_side_by_user_id', $my_user_id ); |
| 250 |
|
| 251 |
$booking_id = isset( $_POST['booking_id'] ) ? sanitize_text_field( wp_unslash( $_POST['booking_id'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ // Booking ID. |
| 252 |
|
| 253 |
$denyreason = isset( $_POST['denyreason'] ) ? sanitize_textarea_field( wp_unslash( $_POST['denyreason'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 254 |
|
| 255 |
if ( ( $denyreason == __( 'Reason for cancellation here', 'booking' ) ) |
| 256 |
|| ( $denyreason == __( 'Reason of cancellation here', 'booking' ) ) |
| 257 |
|| ( $denyreason == 'Reason of cancel here' ) |
| 258 |
) { |
| 259 |
$denyreason = ''; |
| 260 |
} |
| 261 |
|
| 262 |
$is_send_emeils = isset( $_POST['is_send_emeils'] ) ? sanitize_text_field( wp_unslash( $_POST['is_send_emeils'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.NonceVerification.Recommended */ /* FixIn: sanitize_unslash */ |
| 263 |
|
| 264 |
$approved_id = explode( '|', $booking_id ); |
| 265 |
$approved_id = wpbc_clean_digit_or_csd( $approved_id ); // FixIn: 8.4.5.15. |
| 266 |
|
| 267 |
if ( (count($approved_id)>0) && ($approved_id !=false) && ($approved_id !='')) { |
| 268 |
|
| 269 |
$approved_id_str = join( ',', $approved_id); |
| 270 |
$approved_id_str = wpbc_clean_like_string_for_db( $approved_id_str ); |
| 271 |
|
| 272 |
do_action( 'wpbc_booking_delete', $approved_id_str ); // FixIn: 8.7.6.3. |
| 273 |
|
| 274 |
if ( ! empty( $is_send_emeils ) ) { // FixIn: 8.1.3.35. |
| 275 |
wpbc_send_email_deleted( $approved_id_str, $is_send_emeils, $denyreason ); |
| 276 |
} |
| 277 |
|
| 278 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 279 |
if ( false === $wpdb->query( "DELETE FROM {$wpdb->prefix}bookingdates WHERE booking_id IN ({$approved_id_str})" ) ) { |
| 280 |
?> |
| 281 |
<script type="text/javascript"> |
| 282 |
var my_message = '<?php echo esc_attr( html_entity_decode( esc_js( get_debuge_error( 'Error during deleting dates in DB', __FILE__, __LINE__ ) ), ENT_QUOTES ) ); ?>'; |
| 283 |
wpbc_admin_show_message(my_message, 'error', 30000); |
| 284 |
</script> |
| 285 |
<?php |
| 286 |
die(); |
| 287 |
} |
| 288 |
|
| 289 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
| 290 |
if ( false === $wpdb->query( "DELETE FROM {$wpdb->prefix}booking WHERE booking_id IN ({$approved_id_str})" ) ) { |
| 291 |
?> |
| 292 |
<script type="text/javascript"> |
| 293 |
var my_message = '<?php echo esc_attr( html_entity_decode( esc_js( get_debuge_error( 'Error during deleting booking in DB', __FILE__, __LINE__ ) ), ENT_QUOTES ) ); ?>'; |
| 294 |
wpbc_admin_show_message(my_message, 'error', 30000); |
| 295 |
</script> |
| 296 |
<?php |
| 297 |
die(); |
| 298 |
} |
| 299 |
?> |
| 300 |
<script type="text/javascript"> |
| 301 |
<?php foreach ( $approved_id as $bk_id ) { ?> |
| 302 |
set_booking_row_deleted_in_timeline(<?php echo intval( $bk_id ); ?>); |
| 303 |
set_booking_row_deleted(<?php echo intval( $bk_id ); ?>); |
| 304 |
<?php } ?> |
| 305 |
var my_message = '<?php echo esc_attr( html_entity_decode( esc_js( __( 'Deleted', 'booking' ) ), ENT_QUOTES ) ); ?>'; |
| 306 |
wpbc_admin_show_message(my_message, 'success', 3000); |
| 307 |
</script> |
| 308 |
<?php |
| 309 |
} |
| 310 |
} |
| 311 |
|
| 312 |
|
| 313 |
function wpbc_ajax_DELETE_BY_VISITOR() { |
| 314 |
|
| 315 |
if ( wpbc_is_use_nonce_at_front_end() ) { // FixIn: 10.1.1.2. |
| 316 |
|
| 317 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 318 |
if ( ! wpbc_check_nonce_in_admin_panel( $_POST['action'] ) ) { |
| 319 |
return false; // FixIn: 7.2.1.10. |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
make_bk_action( 'wpdev_delete_booking_by_visitor' ); |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
function wpbc_ajax_DELETE_BK_FORM() { |
| 331 |
|
| 332 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 333 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 334 |
make_bk_action('check_multiuser_params_for_client_side_by_user_id', $my_user_id ); |
| 335 |
make_bk_action('wpbc_make_delete_custom_booking_form'); |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
function wpbc_ajax_USER_SAVE_WINDOW_STATE() { |
| 340 |
|
| 341 |
if ( ! wpbc_check_nonce_in_admin_panel() ) { |
| 342 |
return false; |
| 343 |
} |
| 344 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 345 |
$my_window = isset( $_POST['window'] ) ? sanitize_textarea_field( wp_unslash( $_POST['window'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 346 |
$my_is_closed = isset( $_POST['is_closed'] ) ? intval( $_POST['is_closed'] ) : 0; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 347 |
|
| 348 |
update_user_option( $my_user_id, 'booking_win_' . $my_window, $my_is_closed ); |
| 349 |
|
| 350 |
wp_send_json_success(); // FixIn: 7.2.1.10.2 //Fix "400 Bad Request" error showing. At some situations, if Ajax request does not return anything, its will generate an issue. |
| 351 |
} |
| 352 |
|
| 353 |
|
| 354 |
/** Save Custom User Data */ |
| 355 |
function wpbc_ajax_USER_SAVE_CUSTOM_DATA() { |
| 356 |
|
| 357 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; |
| 358 |
/* Exmaple of $_POST: |
| 359 |
[data_name] => add_booking_calendar_options |
| 360 |
[data_value] => calendar_months_count=1&calendar_months_num_in_1_row=1&calendar_width=500px&calendar_cell_height |
| 361 |
*/ |
| 362 |
// "&" was set by jQuery.param( data_params ) in client side. |
| 363 |
|
| 364 |
$my_user_id = isset( $_POST['user_id'] ) ? intval( $_POST['user_id'] ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 365 |
$my_data_name = isset( $_POST['data_name'] ) ? sanitize_textarea_field( wp_unslash( $_POST['data_name'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 366 |
$my_data_value = isset( $_POST['data_value'] ) ? sanitize_textarea_field( wp_unslash( $_POST['data_value'] ) ) : ''; /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ |
| 367 |
|
| 368 |
$post_param = explode( '&', $my_data_value ); |
| 369 |
$data_to_save = array(); |
| 370 |
foreach ( $post_param as $param ) { |
| 371 |
$param_data = explode( '=', $param ); |
| 372 |
|
| 373 |
$data_to_save[ $param_data[0] ] = ( isset( $param_data[1] ) ) ? esc_attr( $param_data[1] ) : ''; |
| 374 |
} |
| 375 |
/* Exmaple: |
| 376 |
Array |
| 377 |
( |
| 378 |
[calendar_months_count] => 1 |
| 379 |
[calendar_months_num_in_1_row] => 1 |
| 380 |
[calendar_width] => 500px |
| 381 |
[calendar_cell_height] => |
| 382 |
) |
| 383 |
*/ |
| 384 |
|
| 385 |
// Save Custom User Data. |
| 386 |
update_user_option( $my_user_id, 'booking_custom_' . $my_data_name, serialize( $data_to_save ) ); |
| 387 |
|
| 388 |
?> <script type="text/javascript"> |
| 389 |
var my_message = '<?php echo esc_js( __('Saved' ,'booking') ) ; ?>'; |
| 390 |
wpbc_admin_show_message( my_message, 'success', 1000 ); |
| 391 |
<?php if ( ! empty( $_POST['is_reload'] ) && intval( $_POST['is_reload'] ) === 1 ) { /* phpcs:ignore WordPress.Security.NonceVerification.Missing */ ?> |
| 392 |
setTimeout(function ( ) {location.reload(true);} ,1500); |
| 393 |
<?php } ?> |
| 394 |
</script> <?php |
| 395 |
die(); |
| 396 |
|
| 397 |
} |
| 398 |
|
| 399 |
|
| 400 |
function wpbc_ajax_BOOKING_SEARCH() { |
| 401 |
|
| 402 |
if ( wpbc_is_use_nonce_at_front_end() ) { // FixIn: 10.1.1.2. |
| 403 |
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotValidated, WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 404 |
if ( ! wpbc_check_nonce_in_admin_panel( $_POST['action'] ) ) { |
| 405 |
return false; // FixIn: 7.2.1.10. |
| 406 |
} |
| 407 |
} |
| 408 |
|
| 409 |
if ( function_exists( 'wpbc_ajax_start_searching' ) ) { |
| 410 |
wpbc_ajax_start_searching(); |
| 411 |
} |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
function wpbc_ajax_CHECK_BK_NEWS() { |
| 416 |
|
| 417 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 418 |
wpbc_old_ajax_check_bk_news(); |
| 419 |
} |
| 420 |
|
| 421 |
|
| 422 |
function wpbc_ajax_CHECK_BK_FEATURES() { |
| 423 |
|
| 424 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 425 |
wpbc_old_ajax_check_bk_news('info/features/'); |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
function wpbc_ajax_CHECK_BK_VERSION() { |
| 430 |
|
| 431 |
if ( ! wpbc_check_nonce_in_admin_panel() ) return false; // FixIn: 7.2.1.10. |
| 432 |
wpbc_old_ajax_check_bk_version(); |
| 433 |
} |
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
// --------------------------------------------------------------------------------------------------------------------- |
| 440 |
// R u n A j a x ////////////////////////////////// |
| 441 |
// --------------------------------------------------------------------------------------------------------------------- |
| 442 |
if ( is_admin() && ( defined( 'DOING_AJAX' ) ) && ( DOING_AJAX ) ) { |
| 443 |
|
| 444 |
// FixIn: 8.9.4.5. |
| 445 |
|
| 446 |
// Hooks list. |
| 447 |
$wpbc_booking_actions_list = array( |
| 448 |
'WPBC_FLEXTIMELINE_NAV' => 'both' //FixIn: Flex TimeLine 1.0 |
| 449 |
,'CALCULATE_THE_COST' => 'both' |
| 450 |
|
| 451 |
|
| 452 |
,'UPDATE_APPROVE' => 'admin' |
| 453 |
,'DELETE_APPROVE' => 'admin' |
| 454 |
,'DELETE_BY_VISITOR' => 'both' |
| 455 |
,'TRASH_RESTORE' => 'admin' // FixIn: 6.1.1.10. |
| 456 |
|
| 457 |
,'DELETE_BK_FORM' => 'admin' |
| 458 |
,'USER_SAVE_WINDOW_STATE' => 'admin' |
| 459 |
,'USER_SAVE_CUSTOM_DATA' => 'admin' |
| 460 |
,'BOOKING_SEARCH' => 'both' |
| 461 |
,'CHECK_BK_NEWS' => 'admin' |
| 462 |
,'CHECK_BK_FEATURES' => 'admin' |
| 463 |
,'CHECK_BK_VERSION' => 'admin' |
| 464 |
|
| 465 |
, 'WPBC_IMPORT_ICS_URL' => 'admin' //FixIn: 7.3 |
| 466 |
); |
| 467 |
|
| 468 |
$wpbc_booking_actions_list = apply_filters( 'wpbc_ajax_action_list', $wpbc_booking_actions_list ); |
| 469 |
|
| 470 |
foreach ( $wpbc_booking_actions_list as $wpbc_action_name => $wpbc_action_where) { |
| 471 |
|
| 472 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing |
| 473 |
if ( ( isset($_POST['action']) ) && ( $_POST['action'] == $wpbc_action_name ) ){ |
| 474 |
|
| 475 |
if ( ( $wpbc_action_where == 'admin' ) || ( $wpbc_action_where == 'both' ) ) |
| 476 |
add_action( 'wp_ajax_' . $wpbc_action_name, 'wpbc_ajax_' . $wpbc_action_name); // Admin & Client (logged in usres) |
| 477 |
|
| 478 |
if ( ( $wpbc_action_where == 'both' ) || ( $wpbc_action_where == 'client' ) ) |
| 479 |
add_action( 'wp_ajax_nopriv_' . $wpbc_action_name, 'wpbc_ajax_' . $wpbc_action_name); // Client (not logged in) |
| 480 |
} |
| 481 |
} |
| 482 |
} |