Version Description
(2022-03-22) = - Fix for conflict between date range exceptions and regular scheduling rules. - Fix for conflict between global date range exceptions and location-specific scheduling rules. - Fix for issue with conditional deposits and reservations being assigned wrong status. - Fix for issue in which certain days were showing all time slots as being available.
Download this release
Release Info
Developer | Rustaurius |
Plugin | Restaurant Reservations |
Version | 2.5.3 |
Comparing to | |
See all releases |
Code changes from version 2.5.2 to 2.5.3
- assets/js/booking-form.js +63 -24
- includes/Ajax.class.php +1 -1
- includes/Booking.class.php +56 -7
- includes/MultipleLocations.class.php +66 -1
- includes/template-functions.php +11 -27
- readme.txt +7 -1
- restaurant-reservations.php +2 -2
assets/js/booking-form.js
CHANGED
@@ -104,28 +104,8 @@ jQuery(document).ready(function ($) {
|
|
104 |
return;
|
105 |
}
|
106 |
|
107 |
-
//
|
108 |
-
|
109 |
-
|
110 |
-
var disable_dates = jQuery.extend( true, [], rtb_pickadate.disable_dates );
|
111 |
-
|
112 |
-
// Update weekday dates if start of the week has been modified
|
113 |
-
if ( typeof rtb_booking_form.datepicker.component.settings.firstDay == 'number' ) {
|
114 |
-
var weekday_num = 0;
|
115 |
-
for ( var disable_key in rtb_pickadate.disable_dates ) {
|
116 |
-
if ( typeof rtb_pickadate.disable_dates[disable_key] == 'number' ) {
|
117 |
-
weekday_num = rtb_pickadate.disable_dates[disable_key] - rtb_booking_form.datepicker.component.settings.firstDay;
|
118 |
-
if ( weekday_num < 1 ) {
|
119 |
-
weekday_num = 7;
|
120 |
-
}
|
121 |
-
disable_dates[disable_key] = weekday_num;
|
122 |
-
}
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
rtb_booking_form.datepicker.set( 'disable', disable_dates );
|
127 |
-
|
128 |
-
}
|
129 |
|
130 |
if ( typeof rtb_pickadate.late_bookings === 'string' ) {
|
131 |
if ( rtb_pickadate.late_bookings == 'same_day' ) {
|
@@ -197,9 +177,14 @@ jQuery(document).ready(function ($) {
|
|
197 |
if ( ! rtb_pickadate.multiple_locations_enabled ) { return; }
|
198 |
|
199 |
rtb_booking_form.timepicker.clear();
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
rtb_booking_form.update_timepicker_range();
|
202 |
-
|
203 |
rtb_booking_form.update_party_size_select();
|
204 |
});
|
205 |
|
@@ -207,6 +192,59 @@ jQuery(document).ready(function ($) {
|
|
207 |
}
|
208 |
};
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
/**
|
211 |
* Update the timepicker's range based on the currently selected date
|
212 |
*/
|
@@ -321,7 +359,8 @@ jQuery(document).ready(function ($) {
|
|
321 |
}
|
322 |
else {
|
323 |
// Set anything to void this rule
|
324 |
-
|
|
|
325 |
excp_date.setDate( selected_date_year + 1 );
|
326 |
}
|
327 |
}
|
104 |
return;
|
105 |
}
|
106 |
|
107 |
+
// Update disabled dates
|
108 |
+
rtb_booking_form.update_disabled_dates();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
if ( typeof rtb_pickadate.late_bookings === 'string' ) {
|
111 |
if ( rtb_pickadate.late_bookings == 'same_day' ) {
|
177 |
if ( ! rtb_pickadate.multiple_locations_enabled ) { return; }
|
178 |
|
179 |
rtb_booking_form.timepicker.clear();
|
180 |
+
rtb_booking_form.datepicker.clear();
|
181 |
+
|
182 |
+
rtb_booking_form.update_base_data_for_selected_location();
|
183 |
+
|
184 |
+
rtb_booking_form.update_datepicker();
|
185 |
|
186 |
rtb_booking_form.update_timepicker_range();
|
187 |
+
|
188 |
rtb_booking_form.update_party_size_select();
|
189 |
});
|
190 |
|
192 |
}
|
193 |
};
|
194 |
|
195 |
+
/**
|
196 |
+
* Update base data for date/time picker as per the selected location
|
197 |
+
* @return object
|
198 |
+
*/
|
199 |
+
rtb_booking_form.update_base_data_for_selected_location = function () {
|
200 |
+
const selected_location = jQuery( '#rtb-location' ).length ? jQuery( '#rtb-location' ).val() : '';
|
201 |
+
|
202 |
+
if( '' == selected_location ) {
|
203 |
+
// Set global settings
|
204 |
+
return Object.assign( rtb_pickadate, rtb_location_data.global );
|
205 |
+
}
|
206 |
+
|
207 |
+
return Object.assign( rtb_pickadate, rtb_location_data[selected_location] );
|
208 |
+
}
|
209 |
+
|
210 |
+
rtb_booking_form.update_datepicker = function () {
|
211 |
+
|
212 |
+
// Reset enabled/disabled rules on this datepicker
|
213 |
+
rtb_booking_form.datepicker.set( 'enable', false );
|
214 |
+
rtb_booking_form.datepicker.set( 'disable', false );
|
215 |
+
|
216 |
+
rtb_booking_form.update_disabled_dates();
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Update datepicker to change the disabled dates based on location
|
221 |
+
*/
|
222 |
+
rtb_booking_form.update_disabled_dates = function() {
|
223 |
+
|
224 |
+
// Pass conditional configuration parameters
|
225 |
+
if ( rtb_pickadate.disable_dates.length ) {
|
226 |
+
|
227 |
+
var disable_dates = jQuery.extend( true, [], rtb_pickadate.disable_dates );
|
228 |
+
|
229 |
+
// Update weekday dates if start of the week has been modified
|
230 |
+
if ( typeof rtb_booking_form.datepicker.component.settings.firstDay == 'number' ) {
|
231 |
+
var weekday_num = 0;
|
232 |
+
for ( var disable_key in rtb_pickadate.disable_dates ) {
|
233 |
+
if ( typeof rtb_pickadate.disable_dates[disable_key] == 'number' ) {
|
234 |
+
weekday_num = rtb_pickadate.disable_dates[disable_key] - rtb_booking_form.datepicker.component.settings.firstDay;
|
235 |
+
if ( weekday_num < 1 ) {
|
236 |
+
weekday_num = 7;
|
237 |
+
}
|
238 |
+
disable_dates[disable_key] = weekday_num;
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
rtb_booking_form.datepicker.set( 'disable', disable_dates );
|
244 |
+
|
245 |
+
}
|
246 |
+
}
|
247 |
+
|
248 |
/**
|
249 |
* Update the timepicker's range based on the currently selected date
|
250 |
*/
|
359 |
}
|
360 |
else {
|
361 |
// Set anything to void this rule
|
362 |
+
// Dates assign with copy, thus creating a new one
|
363 |
+
excp_date = new Date( selected_date.getTime() );
|
364 |
excp_date.setDate( selected_date_year + 1 );
|
365 |
}
|
366 |
}
|
includes/Ajax.class.php
CHANGED
@@ -793,7 +793,7 @@ if ( !class_exists( 'rtbAJAX' ) ) {
|
|
793 |
|
794 |
if ( ! isset( $this->year ) or ! isset( $this->month ) or ! isset( $this->day ) or ! isset( $this->time ) ) { return false; }
|
795 |
|
796 |
-
$datetime =
|
797 |
|
798 |
$valid_tables = rtb_get_valid_tables( $datetime );
|
799 |
|
793 |
|
794 |
if ( ! isset( $this->year ) or ! isset( $this->month ) or ! isset( $this->day ) or ! isset( $this->time ) ) { return false; }
|
795 |
|
796 |
+
$datetime = $this->year . '-' . $this->month . '-' . $this->day . ' ' . $this->time;
|
797 |
|
798 |
$valid_tables = rtb_get_valid_tables( $datetime );
|
799 |
|
includes/Booking.class.php
CHANGED
@@ -378,6 +378,7 @@ class rtbBooking {
|
|
378 |
|
379 |
// Check against scheduling exception rules
|
380 |
$exception_rules = $rtb_controller->settings->get_setting( 'schedule-closed' );
|
|
|
381 |
if (
|
382 |
empty( $this->validation_errors )
|
383 |
&& !empty( $exception_rules )
|
@@ -1108,16 +1109,31 @@ class rtbBooking {
|
|
1108 |
return false;
|
1109 |
}
|
1110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1111 |
/**
|
1112 |
-
*
|
1113 |
-
* where reservations get automatically confirmed
|
1114 |
*
|
1115 |
* @since 2.0.0
|
1116 |
*/
|
1117 |
public function is_time_based_deposit_applicable() {
|
1118 |
global $rtb_controller;
|
1119 |
|
1120 |
-
$deposit_applicable = is_array( $rtb_controller->settings->get_setting( 'rtb-deposit-schedule' ) )
|
|
|
|
|
1121 |
|
1122 |
// Get any rules which apply to this weekday
|
1123 |
if ( $deposit_applicable != 'undefined' ) {
|
@@ -1137,8 +1153,8 @@ class rtbBooking {
|
|
1137 |
|
1138 |
if ( $weekday == $day_of_week ) {
|
1139 |
|
1140 |
-
//
|
1141 |
-
if ( $applicable['time'] == 'undefined' ) {
|
1142 |
|
1143 |
return true;
|
1144 |
}
|
@@ -1169,7 +1185,7 @@ class rtbBooking {
|
|
1169 |
}
|
1170 |
}
|
1171 |
}
|
1172 |
-
}
|
1173 |
|
1174 |
return false;
|
1175 |
}
|
@@ -1295,7 +1311,25 @@ class rtbBooking {
|
|
1295 |
|
1296 |
if ( !empty( $_POST['rtb-post-status'] ) && array_key_exists( $_POST['rtb-post-status'], $rtb_controller->cpts->booking_statuses ) ) {
|
1297 |
$post_status = sanitize_text_field( $_POST['rtb-post-status'] );
|
1298 |
-
} elseif (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1299 |
$post_status = 'payment_pending';
|
1300 |
} elseif ( $this->party < $rtb_controller->settings->get_setting( 'auto-confirm-max-party-size' ) ) {
|
1301 |
$post_status = 'confirmed';
|
@@ -1447,5 +1481,20 @@ class rtbBooking {
|
|
1447 |
do_action( 'rtb_booking_paid', $this );
|
1448 |
}
|
1449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1450 |
}
|
1451 |
} // endif;
|
378 |
|
379 |
// Check against scheduling exception rules
|
380 |
$exception_rules = $rtb_controller->settings->get_setting( 'schedule-closed' );
|
381 |
+
$exception_is_active = false;
|
382 |
if (
|
383 |
empty( $this->validation_errors )
|
384 |
&& !empty( $exception_rules )
|
1109 |
return false;
|
1110 |
}
|
1111 |
|
1112 |
+
/**
|
1113 |
+
* Should we ask for deposit based on required minimum party size?
|
1114 |
+
* @param string $value [description]
|
1115 |
+
*/
|
1116 |
+
public function is_size_based_deposit_applicable() {
|
1117 |
+
global $rtb_controller;
|
1118 |
+
|
1119 |
+
if ($this->party > $rtb_controller->settings->get_setting( 'rtb-deposit-min-party-size' ) ) {
|
1120 |
+
return true;
|
1121 |
+
}
|
1122 |
+
|
1123 |
+
return false;
|
1124 |
+
}
|
1125 |
+
|
1126 |
/**
|
1127 |
+
* Shoudl we ask for deposit or not based on the given schedule?
|
|
|
1128 |
*
|
1129 |
* @since 2.0.0
|
1130 |
*/
|
1131 |
public function is_time_based_deposit_applicable() {
|
1132 |
global $rtb_controller;
|
1133 |
|
1134 |
+
$deposit_applicable = is_array( $rtb_controller->settings->get_setting( 'rtb-deposit-schedule' ) )
|
1135 |
+
? $rtb_controller->settings->get_setting( 'rtb-deposit-schedule' )
|
1136 |
+
: array();
|
1137 |
|
1138 |
// Get any rules which apply to this weekday
|
1139 |
if ( $deposit_applicable != 'undefined' ) {
|
1153 |
|
1154 |
if ( $weekday == $day_of_week ) {
|
1155 |
|
1156 |
+
// applicable all day
|
1157 |
+
if ( !isset( $applicable['time'] ) || $applicable['time'] == 'undefined' ) {
|
1158 |
|
1159 |
return true;
|
1160 |
}
|
1185 |
}
|
1186 |
}
|
1187 |
}
|
1188 |
+
}
|
1189 |
|
1190 |
return false;
|
1191 |
}
|
1311 |
|
1312 |
if ( !empty( $_POST['rtb-post-status'] ) && array_key_exists( $_POST['rtb-post-status'], $rtb_controller->cpts->booking_statuses ) ) {
|
1313 |
$post_status = sanitize_text_field( $_POST['rtb-post-status'] );
|
1314 |
+
} elseif (
|
1315 |
+
(
|
1316 |
+
$rtb_controller->settings->get_setting( 'require-deposit' )
|
1317 |
+
&& ! $payment_made
|
1318 |
+
&& ! $this->is_conditional_deposit_enabled()
|
1319 |
+
)
|
1320 |
+
||
|
1321 |
+
(
|
1322 |
+
$rtb_controller->settings->get_setting( 'require-deposit' )
|
1323 |
+
&& ! $payment_made
|
1324 |
+
&& $this->is_conditional_deposit_enabled()
|
1325 |
+
&&
|
1326 |
+
(
|
1327 |
+
( $this->is_time_based_deposit_enabled() && $this->is_time_based_deposit_applicable() )
|
1328 |
+
||
|
1329 |
+
( $this->is_size_based_deposit_enabled() && $this->is_size_based_deposit_applicable() )
|
1330 |
+
)
|
1331 |
+
)
|
1332 |
+
) {
|
1333 |
$post_status = 'payment_pending';
|
1334 |
} elseif ( $this->party < $rtb_controller->settings->get_setting( 'auto-confirm-max-party-size' ) ) {
|
1335 |
$post_status = 'confirmed';
|
1481 |
do_action( 'rtb_booking_paid', $this );
|
1482 |
}
|
1483 |
|
1484 |
+
function is_conditional_deposit_enabled() {
|
1485 |
+
global $rtb_controller;
|
1486 |
+
return in_array( $rtb_controller->settings->get_setting( 'rtb-deposit-applicable' ), ['time_based', 'size_based'] );
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
function is_time_based_deposit_enabled() {
|
1490 |
+
global $rtb_controller;
|
1491 |
+
return 'time_based' === $rtb_controller->settings->get_setting( 'rtb-deposit-applicable' );
|
1492 |
+
}
|
1493 |
+
|
1494 |
+
function is_size_based_deposit_enabled() {
|
1495 |
+
global $rtb_controller;
|
1496 |
+
return 'size_based' === $rtb_controller->settings->get_setting( 'rtb-deposit-applicable' );
|
1497 |
+
}
|
1498 |
+
|
1499 |
}
|
1500 |
} // endif;
|
includes/MultipleLocations.class.php
CHANGED
@@ -91,7 +91,8 @@ if ( ! class_exists( 'rtbMultipleLocations', false ) ) {
|
|
91 |
add_filter( 'rtb_notification_template_tag_descriptions', array( $this, 'notification_template_tag_descriptions' ) );
|
92 |
add_action( 'admin_init', array( $this, 'fix_autodraft_term_error' ) );
|
93 |
add_filter( 'rtb_settings_page', array( $this, 'maybe_add_location_settings' ) );
|
94 |
-
add_action( 'admin_init', array( $this, 'remove_location_select_setting' ) );
|
|
|
95 |
}
|
96 |
|
97 |
/**
|
@@ -1005,5 +1006,69 @@ if ( ! class_exists( 'rtbMultipleLocations', false ) ) {
|
|
1005 |
|
1006 |
return ( ! empty( $terms ) and ! is_wp_error( $terms ) );
|
1007 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
}
|
1009 |
}
|
91 |
add_filter( 'rtb_notification_template_tag_descriptions', array( $this, 'notification_template_tag_descriptions' ) );
|
92 |
add_action( 'admin_init', array( $this, 'fix_autodraft_term_error' ) );
|
93 |
add_filter( 'rtb_settings_page', array( $this, 'maybe_add_location_settings' ) );
|
94 |
+
add_action( 'admin_init', array( $this, 'remove_location_select_setting' ) );
|
95 |
+
add_filter( 'rtb_booking_form_init', array( $this, 'pass_location_data_to_js' ) );
|
96 |
}
|
97 |
|
98 |
/**
|
1006 |
|
1007 |
return ( ! empty( $terms ) and ! is_wp_error( $terms ) );
|
1008 |
}
|
1009 |
+
|
1010 |
+
function pass_location_data_to_js( $shortcode_arg ) {
|
1011 |
+
global $rtb_controller;
|
1012 |
+
|
1013 |
+
$is_location_specific_shortcode = false;
|
1014 |
+
|
1015 |
+
$locations = [
|
1016 |
+
// false means no slug
|
1017 |
+
'global' => false
|
1018 |
+
];
|
1019 |
+
|
1020 |
+
// Specific location
|
1021 |
+
$location_term = $shortcode_arg['location'] ? get_term( $shortcode_arg['location'] ) : false;
|
1022 |
+
if( $location_term and ! is_wp_error( $location_term ) ) {
|
1023 |
+
$locations[$location_term->term_id] = $location_term->slug;
|
1024 |
+
|
1025 |
+
$is_location_specific_shortcode = true;
|
1026 |
+
}
|
1027 |
+
// All locations
|
1028 |
+
else {
|
1029 |
+
$terms = get_terms(
|
1030 |
+
array(
|
1031 |
+
'taxonomy' => $this->location_taxonomy,
|
1032 |
+
'hide_empty' => false,
|
1033 |
+
)
|
1034 |
+
);
|
1035 |
+
|
1036 |
+
$options = array();
|
1037 |
+
foreach( $terms as $term ) {
|
1038 |
+
$archived = get_term_meta( $term->term_id, 'rtb_location_removed', true );
|
1039 |
+
if ( ! $archived ) {
|
1040 |
+
$locations[$term->term_id] = $term->slug;
|
1041 |
+
}
|
1042 |
+
}
|
1043 |
+
}
|
1044 |
+
|
1045 |
+
$data = [];
|
1046 |
+
foreach ($locations as $idx => $slug) {
|
1047 |
+
$data[$idx]['disable_dates'] = rtb_get_datepicker_rules( $slug );
|
1048 |
+
$data[$idx]['schedule_open'] = $rtb_controller->settings->get_setting( 'schedule-open', $slug );
|
1049 |
+
$data[$idx]['schedule_closed'] = $rtb_controller->settings->get_setting( 'schedule-closed', $slug );
|
1050 |
+
$data[$idx]['enable_max_reservations'] = is_admin() && current_user_can( 'manage_bookings' ) ? false : $rtb_controller->settings->get_setting( 'rtb-enable-max-tables', $slug );
|
1051 |
+
$data[$idx]['max_people'] = is_admin() && current_user_can( 'manage_bookings' ) ? 100 : $rtb_controller->settings->get_setting( 'rtb-max-people-count', $slug );
|
1052 |
+
|
1053 |
+
// Also override initial instance of rtb_pickadate to apply location data
|
1054 |
+
if( $is_location_specific_shortcode ) {
|
1055 |
+
add_filter( 'rtb_pickadate_args', function( $variable_list ) use ( $data, $idx ) {
|
1056 |
+
|
1057 |
+
return array_merge( $variable_list, $data[$idx] );
|
1058 |
+
});
|
1059 |
+
}
|
1060 |
+
}
|
1061 |
+
|
1062 |
+
wp_localize_script(
|
1063 |
+
'rtb-booking-form',
|
1064 |
+
'rtb_location_data',
|
1065 |
+
apply_filters(
|
1066 |
+
'rtb_location_data',
|
1067 |
+
$data
|
1068 |
+
)
|
1069 |
+
);
|
1070 |
+
|
1071 |
+
return $shortcode_arg;
|
1072 |
+
}
|
1073 |
}
|
1074 |
}
|
includes/template-functions.php
CHANGED
@@ -33,7 +33,7 @@ function rtb_print_booking_form( $args = array() )
|
|
33 |
{
|
34 |
global $rtb_controller;
|
35 |
|
36 |
-
do_action( 'rtb_booking_form_init' );
|
37 |
|
38 |
// Only allow the form to be displayed once on a page
|
39 |
if ( $rtb_controller->form_rendered === true ) {
|
@@ -54,22 +54,6 @@ function rtb_print_booking_form( $args = array() )
|
|
54 |
$args['location'] = 0;
|
55 |
}
|
56 |
|
57 |
-
// update JS variables
|
58 |
-
$location_term = $args['location'] ? get_term( $args['location'] ) : false;
|
59 |
-
if( $location_term and ! is_wp_error( $location_term ) ) {
|
60 |
-
add_filter( 'rtb_pickadate_args', function( $variable_list ) use ( $location_term ) {
|
61 |
-
global $rtb_controller;
|
62 |
-
|
63 |
-
$variable_list['disable_dates'] = rtb_get_datepicker_rules( $location_term->slug );
|
64 |
-
$variable_list['schedule_open'] = $rtb_controller->settings->get_setting( 'schedule-open', $location_term->slug );
|
65 |
-
$variable_list['schedule_closed'] = $rtb_controller->settings->get_setting( 'schedule-closed', $location_term->slug );
|
66 |
-
$variable_list['enable_max_reservations'] = is_admin() && current_user_can( 'manage_bookings' ) ? false : $rtb_controller->settings->get_setting( 'rtb-enable-max-tables' );
|
67 |
-
$variable_list['max_people'] = is_admin() && current_user_can( 'manage_bookings' ) ? 100 : $rtb_controller->settings->get_setting( 'rtb-max-people-count' );
|
68 |
-
|
69 |
-
return $variable_list;
|
70 |
-
});
|
71 |
-
}
|
72 |
-
|
73 |
// Enqueue assets for the form
|
74 |
rtb_enqueue_assets();
|
75 |
|
@@ -968,8 +952,8 @@ if ( ! function_exists( 'rtb_get_valid_tables') ) {
|
|
968 |
function rtb_get_valid_tables( $datetime ) {
|
969 |
global $rtb_controller;
|
970 |
|
971 |
-
$request_time =
|
972 |
-
|
973 |
if ( ! $request_time ) { return array(); }
|
974 |
|
975 |
$tables = $rtb_controller->settings->get_sorted_tables();
|
@@ -979,23 +963,23 @@ if ( ! function_exists( 'rtb_get_valid_tables') ) {
|
|
979 |
if ( empty( $table_numbers ) ) { return $table_numbers; }
|
980 |
|
981 |
$dining_block_seconds = (int) $rtb_controller->settings->get_setting( 'rtb-dining-block-length' ) * 60 - 1; // Take 1 second off, to avoid bookings that start or end exactly at the beginning of a booking block
|
982 |
-
|
983 |
$args = array(
|
984 |
'posts_per_page' => -1,
|
985 |
'date_range' => 'dates',
|
986 |
-
'start_date' =>
|
987 |
-
'end_date' =>
|
988 |
);
|
989 |
-
|
990 |
require_once( RTB_PLUGIN_DIR . '/includes/Query.class.php' );
|
991 |
$query = new rtbQuery( $args );
|
992 |
$query->prepare_args();
|
993 |
-
|
994 |
// Get all current bookings sorted by date
|
995 |
$bookings = $query->get_bookings();
|
996 |
|
997 |
-
$request_time_start = $request_time - $dining_block_seconds;
|
998 |
-
$request_time_end = $request_time + $dining_block_seconds;
|
999 |
|
1000 |
$tmzn = wp_timezone();
|
1001 |
|
@@ -1007,7 +991,7 @@ if ( ! function_exists( 'rtb_get_valid_tables') ) {
|
|
1007 |
if ( $booking_time < $request_time_start or $booking_time > $request_time_end ) { continue; }
|
1008 |
|
1009 |
if ( ! isset( $booking->table ) or ! is_array( $booking->table ) ) { continue; }
|
1010 |
-
|
1011 |
$remaining_tables = array_diff( $table_numbers, $booking->table );
|
1012 |
$table_numbers = $remaining_tables;
|
1013 |
}
|
33 |
{
|
34 |
global $rtb_controller;
|
35 |
|
36 |
+
do_action( 'rtb_booking_form_init', $args );
|
37 |
|
38 |
// Only allow the form to be displayed once on a page
|
39 |
if ( $rtb_controller->form_rendered === true ) {
|
54 |
$args['location'] = 0;
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
// Enqueue assets for the form
|
58 |
rtb_enqueue_assets();
|
59 |
|
952 |
function rtb_get_valid_tables( $datetime ) {
|
953 |
global $rtb_controller;
|
954 |
|
955 |
+
$request_time = new DateTime( $datetime, wp_timezone() );
|
956 |
+
|
957 |
if ( ! $request_time ) { return array(); }
|
958 |
|
959 |
$tables = $rtb_controller->settings->get_sorted_tables();
|
963 |
if ( empty( $table_numbers ) ) { return $table_numbers; }
|
964 |
|
965 |
$dining_block_seconds = (int) $rtb_controller->settings->get_setting( 'rtb-dining-block-length' ) * 60 - 1; // Take 1 second off, to avoid bookings that start or end exactly at the beginning of a booking block
|
966 |
+
|
967 |
$args = array(
|
968 |
'posts_per_page' => -1,
|
969 |
'date_range' => 'dates',
|
970 |
+
'start_date' => $request_time->format( 'Y-m-d' ),
|
971 |
+
'end_date' => $request_time->format( 'Y-m-d' )
|
972 |
);
|
973 |
+
|
974 |
require_once( RTB_PLUGIN_DIR . '/includes/Query.class.php' );
|
975 |
$query = new rtbQuery( $args );
|
976 |
$query->prepare_args();
|
977 |
+
|
978 |
// Get all current bookings sorted by date
|
979 |
$bookings = $query->get_bookings();
|
980 |
|
981 |
+
$request_time_start = intval( $request_time->format( 'U' ) ) - $dining_block_seconds;
|
982 |
+
$request_time_end = intval( $request_time->format( 'U' ) ) + $dining_block_seconds;
|
983 |
|
984 |
$tmzn = wp_timezone();
|
985 |
|
991 |
if ( $booking_time < $request_time_start or $booking_time > $request_time_end ) { continue; }
|
992 |
|
993 |
if ( ! isset( $booking->table ) or ! is_array( $booking->table ) ) { continue; }
|
994 |
+
|
995 |
$remaining_tables = array_diff( $table_numbers, $booking->table );
|
996 |
$table_numbers = $remaining_tables;
|
997 |
}
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: FiveStarPlugins
|
|
3 |
Requires at Least: 4.4
|
4 |
Tested Up To: 5.9
|
5 |
Tags: reservation, reservations, restaurant reservations, reservation form, restaurant booking, restaurant reservation form, restaurant booking form, restaurant booking system, reservation system, online reservations, online restaurant booking, dinner reservations, restaurant form, gutenberg reservations, gutenberg restaurant reservations, gutenberg restaurant booking, mobile reservations, responsive reservations, table reservations, open table, book table, reserve table, easy reservations, simple reservations, quick restaurant reservations, custom reservation form, custom restaurant reservations
|
6 |
-
Stable tag: 2.5.
|
7 |
License: GPLv3
|
8 |
License URI:http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Donate Link: https://www.etoilewebdesign.com/plugin-donations/
|
@@ -198,6 +198,12 @@ Find answers to even more questions in the [FAQ](http://doc.fivestarplugins.com/
|
|
198 |
|
199 |
== Changelog ==
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
= 2.5.2 (2022-03-16) =
|
202 |
- Updated nonces.
|
203 |
- Fixes for conflicts with date range exceptions and regular scheduling rules.
|
3 |
Requires at Least: 4.4
|
4 |
Tested Up To: 5.9
|
5 |
Tags: reservation, reservations, restaurant reservations, reservation form, restaurant booking, restaurant reservation form, restaurant booking form, restaurant booking system, reservation system, online reservations, online restaurant booking, dinner reservations, restaurant form, gutenberg reservations, gutenberg restaurant reservations, gutenberg restaurant booking, mobile reservations, responsive reservations, table reservations, open table, book table, reserve table, easy reservations, simple reservations, quick restaurant reservations, custom reservation form, custom restaurant reservations
|
6 |
+
Stable tag: 2.5.3
|
7 |
License: GPLv3
|
8 |
License URI:http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
Donate Link: https://www.etoilewebdesign.com/plugin-donations/
|
198 |
|
199 |
== Changelog ==
|
200 |
|
201 |
+
= 2.5.3 (2022-03-22) =
|
202 |
+
- Fix for conflict between date range exceptions and regular scheduling rules.
|
203 |
+
- Fix for conflict between global date range exceptions and location-specific scheduling rules.
|
204 |
+
- Fix for issue with conditional deposits and reservations being assigned wrong status.
|
205 |
+
- Fix for issue in which certain days were showing all time slots as being available.
|
206 |
+
|
207 |
= 2.5.2 (2022-03-16) =
|
208 |
- Updated nonces.
|
209 |
- Fixes for conflicts with date range exceptions and regular scheduling rules.
|
restaurant-reservations.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Five Star Restaurant Reservations - WordPress Booking Plugin
|
4 |
* Plugin URI: http://www.fivestarplugins.com/plugins/five-star-restaurant-reservations/
|
5 |
* Description: Restaurant reservations made easy. Accept bookings online. Quickly confirm or reject reservations, send email notifications, set booking times and more.
|
6 |
-
* Version: 2.5.
|
7 |
* Author: FiveStarPlugins
|
8 |
* Author URI: https://profiles.wordpress.org/fivestarplugins/
|
9 |
* Text Domain: restaurant-reservations
|
@@ -39,7 +39,7 @@ class rtbInit {
|
|
39 |
public function __construct() {
|
40 |
|
41 |
// Common strings
|
42 |
-
define( 'RTB_VERSION', '2.5.
|
43 |
define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
44 |
define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
|
45 |
define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
|
3 |
* Plugin Name: Five Star Restaurant Reservations - WordPress Booking Plugin
|
4 |
* Plugin URI: http://www.fivestarplugins.com/plugins/five-star-restaurant-reservations/
|
5 |
* Description: Restaurant reservations made easy. Accept bookings online. Quickly confirm or reject reservations, send email notifications, set booking times and more.
|
6 |
+
* Version: 2.5.3
|
7 |
* Author: FiveStarPlugins
|
8 |
* Author URI: https://profiles.wordpress.org/fivestarplugins/
|
9 |
* Text Domain: restaurant-reservations
|
39 |
public function __construct() {
|
40 |
|
41 |
// Common strings
|
42 |
+
define( 'RTB_VERSION', '2.5.3' );
|
43 |
define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
|
44 |
define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
|
45 |
define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
|