PluginProbe
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI / 5.8.6
AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI v5.8.6
6.0.3 6.0.2 6.0.1 6.0.0 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.7.9.2 5.7.9.1 5.7.8 5.7.9 5.7.6 5.7.7 5.7.5 5.7.4 5.7.3 5.7.2 5.7.1 trunk 5.6.0 5.6.1 All 34 releases
automatorwp / integrations / wp-booking-calendar / includes / ajax-functions.php

ajax-functions.php in AutomatorWP – No-Code Workflow Automation, Integration & Webhooks Plugin, now with AI 5.8.6, at integrations/wp-booking-calendar/includes/ajax-functions.php

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Ajax Functions
5 *
6 * @package AutomatorWP\BookingCalendar\Ajax_Functions
7 * @since 1.0.0
8 */
9 // Exit if accessed directly
10 if( !defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Ajax function for selecting bookings
14 *
15 * @since 1.0.0
16 */
17 function automatorwp_wp_booking_calendar_ajax_get_bookings() {
18 // Security check
19 check_ajax_referer( 'automatorwp_admin', 'nonce' );
20
21 // Permissions check
22 if( ! current_user_can( automatorwp_get_manager_capability() ) ) {
23 wp_send_json_error( __( 'You\'re not allowed to perform this action.', 'automatorwp' ) );
24 }
25
26 global $wpdb;
27
28 // Pull back the search string
29 $search = isset( $_REQUEST['q'] ) ? $wpdb->esc_like( $_REQUEST['q'] ) : '';
30
31 $results = array();
32
33 // Get the bookings
34 $bookings = $wpdb->get_results( $wpdb->prepare(
35 "SELECT booking_id, sort_date FROM {$wpdb->prefix}booking WHERE booking_id LIKE %s",
36 "%%{$search}%%"
37 ) );
38
39 foreach( $bookings as $booking ) {
40 $results[] = array(
41 'id' => $booking->booking_id,
42 'text' => 'Booking ' . $booking->booking_id . ': ' . $booking->sort_date,
43 );
44 }
45
46 // Prepend option none
47 $results = automatorwp_ajax_get_ajax_results_option_none( $results );
48
49 // Return our results
50 wp_send_json_success( $results );
51 die;
52
53 }
54 add_action( 'wp_ajax_automatorwp_wp_booking_calendar_get_bookings', 'automatorwp_wp_booking_calendar_ajax_get_bookings' );
55