Restaurant Reservations - Version 2.5.5

Version Description

(2022-03-29) = - Updated to timezone based date/time handling throughout the plugin, to have more consistent behaviour for all users, irrespective of their timezone/server.

Download this release

Release Info

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

Code changes from version 2.5.4 to 2.5.5

includes/Booking.class.php CHANGED
@@ -130,7 +130,7 @@ class rtbBooking {
130
 
131
  // Split $date to $request_date and $request_time
132
  if ( empty( $this->request_date ) || empty( $this->request_time ) ) {
133
- $date = new DateTime( $this->date );
134
  $this->request_date = $date->format( 'Y/m/d' );
135
  $this->request_time = $date->format( 'h:i A' );
136
  }
@@ -285,7 +285,7 @@ class rtbBooking {
285
 
286
  } else {
287
  try {
288
- $date = new DateTime( sanitize_text_field( $_POST['rtb-date'] ) );
289
  } catch ( Exception $e ) {
290
  $this->validation_errors[] = array(
291
  'field' => 'date',
@@ -306,7 +306,7 @@ class rtbBooking {
306
 
307
  } else {
308
  try {
309
- $time = new DateTime( sanitize_text_field( $_POST['rtb-time'] ) );
310
  } catch ( Exception $e ) {
311
  $this->validation_errors[] = array(
312
  'field' => 'time',
@@ -320,13 +320,14 @@ class rtbBooking {
320
  if ( is_object( $time ) && is_object( $date ) ) {
321
 
322
  $request = new DateTime( $date->format( 'Y-m-d' ) . ' ' . $time->format( 'H:i:s' ), wp_timezone() );
 
323
 
324
  // Exempt Bookings Managers from the early and late bookings restrictions
325
  if ( !current_user_can( 'manage_bookings' ) ) {
326
 
327
  $early_bookings = $rtb_controller->settings->get_setting( 'early-bookings' );
328
  if ( !empty( $early_bookings ) && is_numeric( $early_bookings ) ) {
329
- $uppar_bound = ( new DateTime( 'now' ) )->setTime( 23, 59 );
330
  $uppar_bound->add( new DateInterval( "P{$early_bookings}D" ) );
331
 
332
  if ( $request > $uppar_bound ) {
@@ -340,7 +341,7 @@ class rtbBooking {
340
 
341
  $late_bookings = $rtb_controller->settings->get_setting( 'late-bookings' );
342
  if ( empty( $late_bookings ) ) {
343
- if ( $request->format( 'U' ) < current_time( 'timestamp' ) ) {
344
  $this->validation_errors[] = array(
345
  'field' => 'time',
346
  'error_msg' => 'Booking request in the past',
@@ -349,7 +350,7 @@ class rtbBooking {
349
  }
350
 
351
  } elseif ( $late_bookings === 'same_day' ) {
352
- if ( $request->format( 'Y-m-d' ) == current_time( 'Y-m-d' ) ) {
353
  $this->validation_errors[] = array(
354
  'field' => 'time',
355
  'error_msg' => 'Booking request made on same day',
@@ -359,7 +360,7 @@ class rtbBooking {
359
 
360
  } elseif( is_numeric( $late_bookings ) ) {
361
  $late_bookings_seconds = $late_bookings * 60; // Late bookings allowance in seconds
362
- if ( $request->format( 'U' ) < ( current_time( 'timestamp' ) + $late_bookings_seconds ) ) {
363
  if ( $late_bookings >= 1440 ) {
364
  $late_bookings_message = sprintf( __( 'Sorry, bookings must be made more than %s days in advance.', 'restaurant-reservations' ), $late_bookings / 1440 );
365
  } elseif ( $late_bookings >= 60 ) {
@@ -451,14 +452,12 @@ class rtbBooking {
451
  $excp_end_time->format( 'U' )
452
  ) {
453
  // If we reach here, means request is under modified whielist rules
454
- // check next rule
455
  $datetime_is_valid = true;
 
456
  }
457
  else {
458
  // else this request falls in blacklisted area based on modified whitelist rules.
459
- // Request denied, terminate loop
460
  $datetime_is_valid = false;
461
- break;
462
  }
463
  }
464
  }
@@ -1418,7 +1417,7 @@ class rtbBooking {
1418
  }
1419
 
1420
  if ( empty( $this->date_submission ) ) {
1421
- $meta['date_submission'] = current_time( 'timestamp' );
1422
  } else {
1423
  $meta['date_submission'] = $this->date_submission;
1424
  }
130
 
131
  // Split $date to $request_date and $request_time
132
  if ( empty( $this->request_date ) || empty( $this->request_time ) ) {
133
+ $date = new DateTime( $this->date, wp_timezone() );
134
  $this->request_date = $date->format( 'Y/m/d' );
135
  $this->request_time = $date->format( 'h:i A' );
136
  }
285
 
286
  } else {
287
  try {
288
+ $date = new DateTime( sanitize_text_field( $_POST['rtb-date'] ), wp_timezone() );
289
  } catch ( Exception $e ) {
290
  $this->validation_errors[] = array(
291
  'field' => 'date',
306
 
307
  } else {
308
  try {
309
+ $time = new DateTime( sanitize_text_field( $_POST['rtb-time'] ), wp_timezone() );
310
  } catch ( Exception $e ) {
311
  $this->validation_errors[] = array(
312
  'field' => 'time',
320
  if ( is_object( $time ) && is_object( $date ) ) {
321
 
322
  $request = new DateTime( $date->format( 'Y-m-d' ) . ' ' . $time->format( 'H:i:s' ), wp_timezone() );
323
+ $this->date_submission = new DateTime( 'now', wp_timezone() );
324
 
325
  // Exempt Bookings Managers from the early and late bookings restrictions
326
  if ( !current_user_can( 'manage_bookings' ) ) {
327
 
328
  $early_bookings = $rtb_controller->settings->get_setting( 'early-bookings' );
329
  if ( !empty( $early_bookings ) && is_numeric( $early_bookings ) ) {
330
+ $uppar_bound = ( new DateTime( 'now', wp_timezone() ) )->setTime( 23, 59 );
331
  $uppar_bound->add( new DateInterval( "P{$early_bookings}D" ) );
332
 
333
  if ( $request > $uppar_bound ) {
341
 
342
  $late_bookings = $rtb_controller->settings->get_setting( 'late-bookings' );
343
  if ( empty( $late_bookings ) ) {
344
+ if ( $request->format( 'U' ) < $this->date_submission->format( 'U' ) ) {
345
  $this->validation_errors[] = array(
346
  'field' => 'time',
347
  'error_msg' => 'Booking request in the past',
350
  }
351
 
352
  } elseif ( $late_bookings === 'same_day' ) {
353
+ if ( $request->format( 'Y-m-d' ) == $this->date_submission->format( 'Y-m-d' ) ) {
354
  $this->validation_errors[] = array(
355
  'field' => 'time',
356
  'error_msg' => 'Booking request made on same day',
360
 
361
  } elseif( is_numeric( $late_bookings ) ) {
362
  $late_bookings_seconds = $late_bookings * 60; // Late bookings allowance in seconds
363
+ if ( $request->format( 'U' ) < ( $this->date_submission->format( 'U' ) + $late_bookings_seconds ) ) {
364
  if ( $late_bookings >= 1440 ) {
365
  $late_bookings_message = sprintf( __( 'Sorry, bookings must be made more than %s days in advance.', 'restaurant-reservations' ), $late_bookings / 1440 );
366
  } elseif ( $late_bookings >= 60 ) {
452
  $excp_end_time->format( 'U' )
453
  ) {
454
  // If we reach here, means request is under modified whielist rules
 
455
  $datetime_is_valid = true;
456
+ break;
457
  }
458
  else {
459
  // else this request falls in blacklisted area based on modified whitelist rules.
 
460
  $datetime_is_valid = false;
 
461
  }
462
  }
463
  }
1417
  }
1418
 
1419
  if ( empty( $this->date_submission ) ) {
1420
+ $meta['date_submission'] = (new DateTime( 'now', wp_timezone() ))->format( 'U' );
1421
  } else {
1422
  $meta['date_submission'] = $this->date_submission;
1423
  }
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.4
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,9 @@ Find answers to even more questions in the [FAQ](http://doc.fivestarplugins.com/
198
 
199
  == Changelog ==
200
 
 
 
 
201
  = 2.5.4 (2022-03-28) =
202
  - Fixed rare issue in which the reservation date would save as one year later than booked.
203
 
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.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
 
199
  == Changelog ==
200
 
201
+ = 2.5.5 (2022-03-29) =
202
+ - Updated to timezone based date/time handling throughout the plugin, to have more consistent behaviour for all users, irrespective of their timezone/server.
203
+
204
  = 2.5.4 (2022-03-28) =
205
  - Fixed rare issue in which the reservation date would save as one year later than booked.
206
 
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.4
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.4' );
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__ ) );
@@ -401,11 +401,37 @@ class rtbInit {
401
  ?>
402
  <div class="rtb-admin-header-menu">
403
  <h2 class="nav-tab-wrapper">
404
- <a id="rtb-dash-mobile-menu-open" href="#" class="menu-tab nav-tab"><?php _e("MENU", 'restaurant-reservations'); ?><span id="rtb-dash-mobile-menu-down-caret">&nbsp;&nbsp;&#9660;</span><span id="rtb-dash-mobile-menu-up-caret">&nbsp;&nbsp;&#9650;</span></a>
405
- <a id="dashboard-menu" href='admin.php?page=rtb-dashboard' class="menu-tab nav-tab <?php if ($screenID == 'bookings_page_rtb-dashboard') {echo 'nav-tab-active';}?>"><?php _e("Dashboard", 'restaurant-reservations'); ?></a>
406
- <a id="bookings-menu" href='admin.php?page=rtb-bookings' class="menu-tab nav-tab <?php if ($screenID == 'toplevel_page_rtb-bookings') {echo 'nav-tab-active';}?>"><?php _e("Bookings", 'restaurant-reservations'); ?></a>
407
- <a id="options-menu" href='admin.php?page=rtb-settings' class="menu-tab nav-tab <?php if ($screenID == 'bookings_page_rtb-settings') {echo 'nav-tab-active';}?>"><?php _e("Settings", 'restaurant-reservations'); ?></a>
408
- <?php if ($rtb_controller->permissions->check_permission( 'custom_fields' ) ) { ?><a id="customfields-menu" href='admin.php?page=cffrtb-editor' class="menu-tab nav-tab <?php if ($screenID == 'bookings_page_cffrtb-editor') {echo 'nav-tab-active';}?>"><?php _e("Custom Fields", 'restaurant-reservations'); ?></a><?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  </h2>
410
  </div>
411
  <?php
@@ -602,22 +628,23 @@ class rtbInit {
602
  }
603
  }
604
 
605
- /**
606
- * Handle the codebase combination
607
  * @since 2.0
608
  */
609
- public function output_buffer_start()
610
- {
611
  ob_start();
612
  }
613
 
614
  /**
615
- * Handle the codebase combination
616
  * @since 2.0
617
  */
618
- public function output_buffer_end()
619
- {
620
- if( count(ob_list_handlers()) ) {
 
621
  ob_end_flush();
622
  }
623
  }
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.5
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.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__ ) );
401
  ?>
402
  <div class="rtb-admin-header-menu">
403
  <h2 class="nav-tab-wrapper">
404
+ <a id="rtb-dash-mobile-menu-open" href="#" class="menu-tab nav-tab">
405
+ <?php _e("MENU", 'restaurant-reservations'); ?>
406
+ <span id="rtb-dash-mobile-menu-down-caret">&nbsp;&nbsp;&#9660;</span>
407
+ <span id="rtb-dash-mobile-menu-up-caret">&nbsp;&nbsp;&#9650;</span>
408
+ </a>
409
+
410
+ <?php if( current_user_can( 'manage_options' ) ) { ?>
411
+ <a id="dashboard-menu" href='admin.php?page=rtb-dashboard'
412
+ class="menu-tab nav-tab <?php echo 'bookings_page_rtb-dashboard' == $screenID ? 'nav-tab-active' : ''; ?>">
413
+ <?php _e("Dashboard", 'restaurant-reservations'); ?>
414
+ </a>
415
+ <?php } ?>
416
+
417
+ <a id="bookings-menu" href='admin.php?page=rtb-bookings'
418
+ class="menu-tab nav-tab <?php echo 'toplevel_page_rtb-bookings' == $screenID ? 'nav-tab-active' : ''; ?>">
419
+ <?php _e("Bookings", 'restaurant-reservations'); ?>
420
+ </a>
421
+
422
+ <?php if( current_user_can( 'manage_options' ) ) { ?>
423
+ <a id="options-menu" href='admin.php?page=rtb-settings'
424
+ class="menu-tab nav-tab <?php echo 'bookings_page_rtb-settings' == $screenID ? 'nav-tab-active' : ''; ?>">
425
+ <?php _e("Settings", 'restaurant-reservations'); ?>
426
+ </a>
427
+ <?php } ?>
428
+
429
+ <?php if ( current_user_can( 'manage_options' ) && $rtb_controller->permissions->check_permission( 'custom_fields' ) ) { ?>
430
+ <a id="customfields-menu" href='admin.php?page=cffrtb-editor'
431
+ class="menu-tab nav-tab <?php echo 'bookings_page_cffrtb-editor' == $screenID ? 'nav-tab-active' : '';?>">
432
+ <?php _e("Custom Fields", 'restaurant-reservations'); ?>
433
+ </a>
434
+ <?php } ?>
435
  </h2>
436
  </div>
437
  <?php
628
  }
629
  }
630
 
631
+ /**
632
+ * Start an output buffer
633
  * @since 2.0
634
  */
635
+ public function output_buffer_start() {
636
+
637
  ob_start();
638
  }
639
 
640
  /**
641
+ * Close our output buffer, if not already closed
642
  * @since 2.0
643
  */
644
+ public function output_buffer_end() {
645
+
646
+ if ( count( ob_list_handlers() ) ) {
647
+
648
  ob_end_flush();
649
  }
650
  }