Restaurant Reservations - Version 2.1.10

Version Description

(2020-06-16) = - Fixes timezone issues that some users were having for their reservation reminders and max reservation/late bookings settings

Download this release

Release Info

Developer Rustaurius
Plugin Icon 128x128 Restaurant Reservations
Version 2.1.10
Comparing to
See all releases

Code changes from version 2.1.9 to 2.1.10

assets/js/admin.js CHANGED
@@ -1022,6 +1022,25 @@ jQuery(document).ready(function($){
1022
 
1023
  /*LOCK BOXES*/
1024
  jQuery(document).ready(function($){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1025
  $(function(){
1026
  $(window).resize(function(){
1027
  $('.rtb-premium-options-table-overlay').each(function(){
1022
 
1023
  /*LOCK BOXES*/
1024
  jQuery(document).ready(function($){
1025
+
1026
+ setTimeout(function(){
1027
+ $('.rtb-premium-options-table-overlay').each(function(){
1028
+ var eachProTableOverlay = $(this);
1029
+ var associatedTable = eachProTableOverlay.next();
1030
+ var tableWidth = associatedTable.outerWidth(true);
1031
+ associatedTable.css('min-height', '240px');
1032
+ var tableHeight = associatedTable.outerHeight();
1033
+ var tablePosition = associatedTable.position();
1034
+ var tableLeft = tablePosition.left;
1035
+ var tableTop = tablePosition.top;
1036
+ eachProTableOverlay.css('width', tableWidth+'px');
1037
+ eachProTableOverlay.css('height', tableHeight+'px');
1038
+ eachProTableOverlay.css('left', tableLeft+'px');
1039
+ eachProTableOverlay.css('top', tableTop+'px');
1040
+ })
1041
+ }, 500);
1042
+
1043
+
1044
  $(function(){
1045
  $(window).resize(function(){
1046
  $('.rtb-premium-options-table-overlay').each(function(){
assets/js/booking-form.js CHANGED
@@ -387,11 +387,50 @@ jQuery(document).ready(function ($) {
387
  */
388
  rtb_booking_form.get_latest_viable_time = function( hour, minute ) {
389
 
390
- var outer_time_range = this.get_outer_time_range();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
 
392
- if ( hour > outer_time_range.to[0] || minute > outer_time_range.to[1] ) {
393
- return outer_time_range.to;
 
 
 
 
 
 
 
 
 
 
 
 
394
  } else {
 
395
  return [ hour, minute ];
396
  }
397
  };
387
  */
388
  rtb_booking_form.get_latest_viable_time = function( hour, minute ) {
389
 
390
+ var interval = rtb_booking_form.timepicker.get( 'interval' );
391
+
392
+ var outer_time_range = this.get_outer_time_range();
393
+
394
+ /*
395
+ * Adjust the last time for wide intervals, so that the last time entered
396
+ * corresponds to an interval time. A pickadate bug causes a later time to
397
+ * be available for booking otherwise.
398
+ */
399
+ if ( interval > 60) {
400
+
401
+ var last_hour = 0;
402
+ var last_minute = 0;
403
+ var last_time_minutes = 0;
404
+
405
+ var end_time_minutes = 60 * hour + minute;
406
+
407
+ while ( ( last_time_minutes + interval ) <= end_time_minutes ) {
408
+
409
+ var remainder = interval + last_minute;
410
+
411
+ while ( remainder >= 60 ) {
412
+ last_hour++;
413
+ remainder -= 60;
414
+ }
415
+
416
+ last_minute = remainder;
417
 
418
+ last_time_minutes = 60 * last_hour + last_minute;
419
+ }
420
+
421
+ var long_interval_viable_time = [ last_hour, last_minute ];
422
+ }
423
+
424
+
425
+ if ( interval > 60 ) {
426
+
427
+ return long_interval_viable_time;
428
+ }
429
+ else if ( hour > outer_time_range.to[0] || minute > outer_time_range.to[1] ) {
430
+
431
+ return [ outer_time_range.to[0], outer_time_range.to[1] ];
432
  } else {
433
+
434
  return [ hour, minute ];
435
  }
436
  };
includes/Ajax.class.php CHANGED
@@ -437,15 +437,18 @@ if ( !class_exists( 'rtbAJAX' ) ) {
437
  }
438
 
439
  $late_bookings = ( is_admin() && current_user_can( 'manage_bookings' ) ) ? '' : $rtb_controller->settings->get_setting( 'late-bookings' );
 
 
 
440
 
441
- $open_time = time() > $open_time ? time() : $open_time;
442
 
443
  if ( $late_bookings === 'number' && $late_bookings % 1 === 0 ) {
444
  if ( time() + $late_bookings * 60 > $open_time ) {
445
  $open_time = time() + $late_bookings;
446
  }
447
  }
448
-
449
  return $open_time;
450
  }
451
 
437
  }
438
 
439
  $late_bookings = ( is_admin() && current_user_can( 'manage_bookings' ) ) ? '' : $rtb_controller->settings->get_setting( 'late-bookings' );
440
+
441
+ $timezone = wp_timezone();
442
+ $offset = $timezone->getOffset( new DateTime );
443
 
444
+ $open_time = time() + $offset > $open_time ? time() + $offset : $open_time;
445
 
446
  if ( $late_bookings === 'number' && $late_bookings % 1 === 0 ) {
447
  if ( time() + $late_bookings * 60 > $open_time ) {
448
  $open_time = time() + $late_bookings;
449
  }
450
  }
451
+
452
  return $open_time;
453
  }
454
 
includes/Booking.class.php CHANGED
@@ -866,6 +866,7 @@ class rtbBooking {
866
  'post_title' => $this->name,
867
  'post_content' => $this->message,
868
  'post_date' => $this->date,
 
869
  'post_status' => $this->post_status,
870
  );
871
 
866
  'post_title' => $this->name,
867
  'post_content' => $this->message,
868
  'post_date' => $this->date,
869
+ 'post_date_gmt' => get_gmt_from_date( $this->date ), // fix for post_date_gmt not being set for some bookings
870
  'post_status' => $this->post_status,
871
  );
872
 
includes/Cron.class.php CHANGED
@@ -20,7 +20,7 @@ class rtbCron {
20
  add_action( 'rtb_cron_jobs', array($this, 'handle_late_arrivals_task') );
21
  add_action( 'rtb_cron_jobs', array($this, 'handle_reminder_task') );
22
 
23
- // add_action('admin_init', array($this, 'handle_reminder_task') ); // Used for testing
24
  }
25
 
26
  /**
@@ -130,7 +130,7 @@ class rtbCron {
130
  }
131
 
132
  $notification->set_booking($booking);
133
-
134
  $notification->prepare_notification();
135
 
136
  do_action( 'rtb_send_notification_before', $notification );
@@ -161,17 +161,19 @@ class rtbCron {
161
 
162
  $time_interval = $this->get_time_interval( $count, $unit );
163
 
164
- $after_datetime = new DateTime( '@' . ( time() - ( $time_interval + 3600 ) ) );
165
- $before_datetime = new DateTime( '@' . ( time() - $time_interval ) );
166
 
 
 
167
 
168
  $args = array(
169
  'post_status' => 'confirmed,',
170
  'posts_per_page' => -1,
171
  'date_query' => array(
172
- 'before' => $before_datetime->format( 'c' ),
173
- 'after' => $after_datetime->format( 'c' ),
174
- 'column' => 'post_date_gmt'
175
  )
176
  );
177
  require_once( RTB_PLUGIN_DIR . '/includes/Query.class.php' );
@@ -196,16 +198,19 @@ class rtbCron {
196
 
197
  $time_interval = $this->get_time_interval( $count, $unit );
198
 
199
- $after_datetime = new DateTime( '@' . ( time() - max( $time_interval, 6*3600 ) ) );
200
- $before_datetime = new DateTime( '@' . ( time() + $time_interval ) );
 
 
 
201
 
202
  $args = array(
203
  'post_status' => 'confirmed,',
204
  'post_count' => -1,
205
  'date_query' => array(
206
- 'before' => $before_datetime->format( 'c' ),
207
- 'after' => $after_datetime->format( 'c' ),
208
- 'column' => 'post_date_gmt'
209
  )
210
  );
211
 
20
  add_action( 'rtb_cron_jobs', array($this, 'handle_late_arrivals_task') );
21
  add_action( 'rtb_cron_jobs', array($this, 'handle_reminder_task') );
22
 
23
+ // if ( isset($_GET['debug']) ) { add_action('admin_init', array($this, 'handle_reminder_task') ); } // Used for testing
24
  }
25
 
26
  /**
130
  }
131
 
132
  $notification->set_booking($booking);
133
+
134
  $notification->prepare_notification();
135
 
136
  do_action( 'rtb_send_notification_before', $notification );
161
 
162
  $time_interval = $this->get_time_interval( $count, $unit );
163
 
164
+ $after_datetime = new DateTime( 'now', wp_timezone() );
165
+ $before_datetime = new DateTime( 'now', wp_timezone() );
166
 
167
+ $after_datetime->setTimestamp( time() - ( $time_interval + 3600 ) );
168
+ $before_datetime->setTimestamp( time() - $time_interval );
169
 
170
  $args = array(
171
  'post_status' => 'confirmed,',
172
  'posts_per_page' => -1,
173
  'date_query' => array(
174
+ 'before' => $before_datetime->format( 'Y-m-d H:i:s' ),
175
+ 'after' => $after_datetime->format( 'Y-m-d H:i:s' ),
176
+ 'column' => 'post_date'
177
  )
178
  );
179
  require_once( RTB_PLUGIN_DIR . '/includes/Query.class.php' );
198
 
199
  $time_interval = $this->get_time_interval( $count, $unit );
200
 
201
+ $after_datetime = new DateTime( 'now', wp_timezone() );
202
+ $before_datetime = new DateTime( 'now', wp_timezone() );
203
+
204
+ $after_datetime->setTimestamp( time() - max( $time_interval, 6*3600 ) );
205
+ $before_datetime->setTimestamp( time() + $time_interval );
206
 
207
  $args = array(
208
  'post_status' => 'confirmed,',
209
  'post_count' => -1,
210
  'date_query' => array(
211
+ 'before' => $before_datetime->format( 'Y-m-d H:i:s' ),
212
+ 'after' => $after_datetime->format( 'Y-m-d H:i:s' ),
213
+ 'column' => 'post_date'
214
  )
215
  );
216
 
includes/Dashboard.class.php CHANGED
@@ -116,7 +116,10 @@ class rtbDashboard {
116
  update_option("RTB_Trial_Happening", "No");
117
  delete_option("RTB_Trial_Expiry_Time");
118
 
119
- if ( is_array($Response) and isset($Response['Permission_Level']) and $Response['Permission_Level'] == 3 ) { update_option( "rtb-permission-level", 3 ); }
 
 
 
120
  else { update_option( "rtb-permission-level", 2 ); }
121
  $rtb_controller->permissions->update_permissions();
122
  }
116
  update_option("RTB_Trial_Happening", "No");
117
  delete_option("RTB_Trial_Expiry_Time");
118
 
119
+ if ( is_array($Response) and isset($Response['Permission_Level']) and $Response['Permission_Level'] == 3 ) {
120
+ update_option( 'rtb-ultimate-license-key', $key );
121
+ update_option( "rtb-permission-level", 3 );
122
+ }
123
  else { update_option( "rtb-permission-level", 2 ); }
124
  $rtb_controller->permissions->update_permissions();
125
  }
includes/Notification.SMS.class.php CHANGED
@@ -105,6 +105,8 @@ class rtbNotificationSMS extends rtbNotification {
105
  */
106
  public function set_license_key() {
107
 
 
 
108
  $this->license_key = get_option( 'rtb-ultimate-license-key' );
109
 
110
  }
105
  */
106
  public function set_license_key() {
107
 
108
+ if ( ! get_option( 'rtb-ultimate-license-key' ) ) { add_option( 'rtb-ultimate-license-key', 'no_license_key_entered' ); }
109
+
110
  $this->license_key = get_option( 'rtb-ultimate-license-key' );
111
 
112
  }
includes/Settings.class.php CHANGED
@@ -793,7 +793,6 @@ If you were not the one to cancel this booking, please contact us.
793
  '120' => __( 'Every 120 minutes', 'restaurant-reservations' ),
794
  '90' => __( 'Every 90 minutes', 'restaurant-reservations' ),
795
  '60' => __( 'Every 60 minutes', 'restaurant-reservations' ),
796
- '45' => __( 'Every 45 minutes', 'restaurant-reservations' ),
797
  '' => __( 'Every 30 minutes', 'restaurant-reservations' ),
798
  '15' => __( 'Every 15 minutes', 'restaurant-reservations' ),
799
  '10' => __( 'Every 10 minutes', 'restaurant-reservations' ),
793
  '120' => __( 'Every 120 minutes', 'restaurant-reservations' ),
794
  '90' => __( 'Every 90 minutes', 'restaurant-reservations' ),
795
  '60' => __( 'Every 60 minutes', 'restaurant-reservations' ),
 
796
  '' => __( 'Every 30 minutes', 'restaurant-reservations' ),
797
  '15' => __( 'Every 15 minutes', 'restaurant-reservations' ),
798
  '10' => __( 'Every 10 minutes', 'restaurant-reservations' ),
includes/template-functions.php CHANGED
@@ -475,6 +475,8 @@ function rtb_handle_paypal_ipn() {
475
  $booking = new rtbBooking();
476
  $booking->load_post( $booking_id );
477
 
 
 
478
  $booking->deposit = $payment_amount;
479
  $booking->receipt_id = $paypal_receipt_number;
480
 
@@ -1207,4 +1209,25 @@ if ( ! function_exists( 'rtb_esc_js' ) ) {
1207
 
1208
  return preg_replace( '/[^a-zA-Z ,.-:\/]/', '', $value );
1209
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1210
  }
475
  $booking = new rtbBooking();
476
  $booking->load_post( $booking_id );
477
 
478
+ if ( ! $booking ) { return; }
479
+
480
  $booking->deposit = $payment_amount;
481
  $booking->receipt_id = $paypal_receipt_number;
482
 
1209
 
1210
  return preg_replace( '/[^a-zA-Z ,.-:\/]/', '', $value );
1211
  }
1212
+ }
1213
+
1214
+
1215
+ // Temporary addition, so that versions of WP before 5.3.0 are supported
1216
+ if ( ! function_exists( 'wp_timezone') ) {
1217
+ function wp_timezone() {
1218
+ $timezone_string = get_option( 'timezone_string' );
1219
+
1220
+ if ( ! $timezone_string ) {
1221
+ $offset = (float) get_option( 'gmt_offset' );
1222
+ $hours = (int) $offset;
1223
+ $minutes = ( $offset - $hours );
1224
+
1225
+ $sign = ( $offset < 0 ) ? '-' : '+';
1226
+ $abs_hour = abs( $hours );
1227
+ $abs_mins = abs( $minutes * 60 );
1228
+ $timezone_string = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
1229
+ }
1230
+
1231
+ return new DateTimeZone( $timezone_string );
1232
+ }
1233
  }
readme.txt CHANGED
@@ -196,6 +196,9 @@ Find answers to even more questions in the [FAQ](http://doc.fivestarplugins.com/
196
 
197
  == Changelog ==
198
 
 
 
 
199
  = 2.1.9 (2020-06-11) =
200
  - Adds in error handling, and the ability to retry, for Stripe payments in RTU
201
  - Adds in options for bigger time intervals
196
 
197
  == Changelog ==
198
 
199
+ = 2.1.10 (2020-06-16) =
200
+ - Fixes timezone issues that some users were having for their reservation reminders and max reservation/late bookings settings
201
+
202
  = 2.1.9 (2020-06-11) =
203
  - Adds in error handling, and the ability to retry, for Stripe payments in RTU
204
  - Adds in options for bigger time intervals
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.1.9
7
  * Author: FiveStarPlugins
8
  * Author URI: https://profiles.wordpress.org/fivestarplugins/
9
  * Text Domain: restaurant-reservations
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.1.10
7
  * Author: FiveStarPlugins
8
  * Author URI: https://profiles.wordpress.org/fivestarplugins/
9
  * Text Domain: restaurant-reservations