PluginProbe
Booking Calendar / 11.8.3
Booking Calendar v11.8.3
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 10.11.2 All 203 releases
booking / core / lib / wpbc-ajax.php

wpbc-ajax.php in Booking Calendar 11.8.3, at core/lib/wpbc-ajax.php

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