PluginProbe
Booking Calendar / 11.8.2
Booking Calendar v11.8.2
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 10.11.3 All 202 releases
← All changes | core/wpbc-dev-api.php +79 -7 10.1111.8.2 View file →
@@ -11,14 +11,15 @@
11 11 *
12 12 * @modified 2017-06-24
13 13 */
14 14
15 -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
15 +if ( ! defined( 'ABSPATH' ) ) {
16 + exit; // Exit if accessed directly.
17 +}
16 18
17 -//FixIn: 8.0
18 19
19 20 // ---------------------------------------------------------------------------------------------------------------------
20 -// Add New Booking
21 +// Add New Booking .
21 22 // ---------------------------------------------------------------------------------------------------------------------
22 23 /**
23 24 * Add New Booking
24 25 *
@@ -290,9 +291,9 @@
290 291 // ---------------------------------------------------------------------------------------------------------------------
291 292 // Get Bookings Array - [Listing]
292 293 // ---------------------------------------------------------------------------------------------------------------------
293 294 /**
294 - * Get bookings array from Booking Calendar
295 + * Deprecated: Get bookings array from Booking Calendar
295 296 *
296 297 * @param aray $params
297 298 * @return array
298 299 ( [bookings] => Array (
@@ -455,9 +456,9 @@
455 456 $booking_id = wpbc_clean_digit_or_csd( $booking_id );
456 457
457 458 $slct_sql = $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}booking as b left join {$wpdb->prefix}bookingdates as bd on (b.booking_id = bd.booking_id) WHERE b.booking_id IN (%s) LIMIT 0,1", $booking_id );
458 459
459 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
460 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
460 461 $slct_sql_results = $wpdb->get_results( $slct_sql, ARRAY_A );
461 462
462 463 $data = array();
463 464
@@ -546,9 +547,9 @@
546 547 // $meta_str = "a:2:{s:7:\"general\";s:2:\"On\";s:6:\"filter\";a:3:{i:3;s:3:\"Off\";i:2;s:2:\"On\";i:1;s:3:\"Off\";}}";
547 548 // $wp_queries[] = "INSERT INTO {$wpdb->prefix}booking_types_meta ( type_id, meta_key, meta_value ) VALUES ( {$resource_id}, 'availability', '{$meta_str}' );";
548 549
549 550 foreach ( $wp_queries as $wp_q ) {
550 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared
551 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
551 552 $wpdb->query( $wp_q );
552 553 }
553 554
554 555 // -----------------------------------------------------------------------------------------------------------------
@@ -717,5 +718,76 @@
717 718 * $resources_id_arr = explode( ',', $resources_id_str );
718 719 * // Do something ...
719 720 * }
720 721 * add_action( 'wpbc_deleted_booking_resources', 'my_func__on_resource_delete' );
721 - */
722 + */
723 +
724 +
725 +/**
726 + * Some exmaples of fucntions usage.
727 + *
728 + * @return void
729 + */
730 +function wpbc_create_a_new_booking_exmaple(){
731 +
732 + // -----------------------------------------------------------------------------------------------------------------
733 + // Example #1.
734 + // -----------------------------------------------------------------------------------------------------------------
735 + $booking = array(
736 + 'dates' => array( '2027-06-24', '2027-06-24', '2027-06-25', '2027-06-26' ),
737 + 'data' => array(
738 + 'secondname' => array( 'value' => 'Smith', 'type' => 'text' ),
739 + 'name' => 'Rika',
740 + 'email' => array( 'value' => 'rika@cost.com', 'type' => 'email' ),
741 + )
742 + );
743 + $booking_id = wpbc_api_booking_add_new( $booking['dates'], $booking['data'] );
744 +
745 + // -----------------------------------------------------------------------------------------------------------------
746 + // Example #2. - Add bew booking, without checking if the dates/times are available in source booking resource.
747 + // -----------------------------------------------------------------------------------------------------------------
748 + $booking = array(
749 + 'dates' => array( '2027-08-24', '2027-08-25', '2027-08-26' ),
750 + 'data' => array(
751 + 'rangetime' => array( 'value' => '14:00 - 16:00', 'type' => 'selectbox-one' ), // Define booked time-slot.
752 + 'name' => 'John', // Simple configuration.
753 + 'secondname' => array( 'value' => 'Smith', 'type' => 'text' ), // Advanced configuration.
754 + 'email' => array( 'value' => 'John@cost.com', 'type' => 'email' ),
755 + ),
756 + 'resource_id' => 3,
757 + 'options' => array(
758 + 'save_booking_even_if_unavailable' => 1, // [0 | 1] if 1 - skip checking if the dates/times are available.
759 + ),
760 + );
761 + $booking_id = wpbc_api_booking_add_new( $booking['dates'], $booking['data'], $booking['resource_id'], $booking['options'] );
762 +
763 + // -----------------------------------------------------------------------------------------------------------------
764 + // Example #3. - Check if time slot on specific date available.
765 + // -----------------------------------------------------------------------------------------------------------------
766 + $booking = array(
767 + 'dates' => array( '2027-08-24 15:00:01', '2027-08-24 16:00:02' ),
768 + 'resource_id' => 3,
769 + 'params' => array( 'is_use_booking_recurrent_time' => false ),
770 + );
771 + $is_dates_booked = wpbc_api_is_dates_booked( $booking['dates'], $booking['resource_id'], $booking['params'] );
772 + if ( $is_dates_booked ) {
773 + // Booked.
774 + } else {
775 + // Available.
776 + }
777 +
778 + // -----------------------------------------------------------------------------------------------------------------
779 + // Example #4. - Check if dates available.
780 + // -----------------------------------------------------------------------------------------------------------------
781 + $booking = array(
782 + 'dates' => array( '2027-08-24 00:00:00', '2027-08-25 00:00:00', '2027-08-26 00:00:00' ),
783 + 'resource_id' => 3,
784 + 'params' => array( 'is_use_booking_recurrent_time' => false ),
785 + );
786 + $is_dates_booked = wpbc_api_is_dates_booked( $booking['dates'], $booking['resource_id'], $booking['params'] );
787 + if ( $is_dates_booked ) {
788 + // Booked.
789 + } else {
790 + // Available.
791 + }
792 +
793 +}