Restaurant Reservations - Version 1.1.3

Version Description

This update fixes an error when the form had validation errors (missing fields or wrong date/time selected). Instead of loading the selected date it would load today's date. This update ensures the selected date is reloaded properly.

Download this release

Release Info

Developer NateWr
Plugin Icon 128x128 Restaurant Reservations
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

Files changed (3) hide show
  1. assets/js/booking-form.js +10 -0
  2. readme.txt +7 -1
  3. restaurant-reservations.php +288 -288
assets/js/booking-form.js CHANGED
@@ -39,6 +39,16 @@ jQuery(document).ready(function ($) {
39
  // accordingly.
40
  // @todo support start of the week based on language file
41
  firstDay: 0,
 
 
 
 
 
 
 
 
 
 
42
  });
43
 
44
  // Declare timepicker
39
  // accordingly.
40
  // @todo support start of the week based on language file
41
  firstDay: 0,
42
+
43
+ // Select the value when loaded if a value has been set
44
+ onStart: function() {
45
+ if ( $( '#rtb-date' ).val() !== '' ) {
46
+ var date = new Date( $( '#rtb-date' ).val() );
47
+ if ( Object.prototype.toString.call( date ) === "[object Date]" ) {
48
+ this.set( 'select', date );
49
+ }
50
+ }
51
+ }
52
  });
53
 
54
  // Declare timepicker
readme.txt CHANGED
@@ -5,7 +5,7 @@ Plugin URL: http://themeofthecrop.com
5
  Requires at Least: 3.8
6
  Tested Up To: 3.9.1
7
  Tags: restaurant, reservations, bookings, table bookings, restaurant reservation, table reservation
8
- Stable tag: 1.1.2
9
  License: GPLv2 or later
10
  Donate link: http://themeofthecrop.com
11
 
@@ -56,6 +56,9 @@ This plugin is packed with hooks so you can extend it, customize it and rebrand
56
 
57
  == Changelog ==
58
 
 
 
 
59
  = 1.1.2 (2014-05-14) =
60
  * Update Simple Admin Pages library to fix an uncommon error when saving Textarea components
61
 
@@ -79,6 +82,9 @@ This plugin is packed with hooks so you can extend it, customize it and rebrand
79
 
80
  == Upgrade Notice ==
81
 
 
 
 
82
  = 1.1.2 =
83
  This update fixes an error some people may experience when trying to save settings. This is the second update today, so if you missed the other one please read the changelog for the 1.1.1 update as well.
84
 
5
  Requires at Least: 3.8
6
  Tested Up To: 3.9.1
7
  Tags: restaurant, reservations, bookings, table bookings, restaurant reservation, table reservation
8
+ Stable tag: 1.1.3
9
  License: GPLv2 or later
10
  Donate link: http://themeofthecrop.com
11
 
56
 
57
  == Changelog ==
58
 
59
+ = 1.1.3 (2014-05-22) =
60
+ * Fix an error where the wrong date would be selected when a form was reloaded with validation errors
61
+
62
  = 1.1.2 (2014-05-14) =
63
  * Update Simple Admin Pages library to fix an uncommon error when saving Textarea components
64
 
82
 
83
  == Upgrade Notice ==
84
 
85
+ = 1.1.3 =
86
+ This update fixes an error when the form had validation errors (missing fields or wrong date/time selected). Instead of loading the selected date it would load today's date. This update ensures the selected date is reloaded properly.
87
+
88
  = 1.1.2 =
89
  This update fixes an error some people may experience when trying to save settings. This is the second update today, so if you missed the other one please read the changelog for the 1.1.1 update as well.
90
 
restaurant-reservations.php CHANGED
@@ -1,289 +1,289 @@
1
- <?php
2
- /**
3
- * Plugin Name: Restaurant Reservations
4
- * Plugin URI: http://themeofthecrop.com
5
- * Description: Accept restaurant reservations and bookings online.
6
- * Version: 1.1.2
7
- * Author: Theme of the Crop
8
- * Author URI: http://themeofthecrop.com
9
- * License: GNU General Public License v2.0 or later
10
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
- * Requires at least: 3.8
12
- * Tested up to: 3.9.1
13
- *
14
- * Text Domain: rtbdomain
15
- * Domain Path: /languages/
16
- *
17
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
18
- * General Public License as published by the Free Software Foundation; either version 2 of the License,
19
- * or (at your option) any later version.
20
- *
21
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
22
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
- *
24
- * You should have received a copy of the GNU General Public License along with this program; if not, write
25
- * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
- */
27
- if ( ! defined( 'ABSPATH' ) )
28
- exit;
29
-
30
- if ( !class_exists( 'rtbInit' ) ) {
31
- class rtbInit {
32
-
33
- /**
34
- * Set a flag which tracks whether the form has already been rendered on
35
- * the page. Only one form per page for now.
36
- * @todo support multiple forms per page
37
- */
38
- public $form_rendered = false;
39
-
40
- /**
41
- * Initialize the plugin and register hooks
42
- */
43
- public function __construct() {
44
-
45
- // Common strings
46
- define( 'RTB_TEXTDOMAIN', 'rtbdomain' );
47
- define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
48
- define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
49
- define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
50
- define( 'RTB_BOOKING_POST_TYPE', 'rtb-booking' );
51
- define( 'RTB_BOOKING_POST_TYPE_SLUG', 'booking' );
52
- define( 'RTB_LOAD_FRONTEND_ASSETS', apply_filters( 'rtb-load-frontend-assets', true ) );
53
-
54
-
55
- // Initialize the plugin
56
- add_action( 'init', array( $this, 'load_textdomain' ) );
57
-
58
- // Add custom roles and capabilities
59
- add_action( 'init', array( $this, 'add_roles' ) );
60
-
61
- // Load custom post types
62
- require_once( RTB_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
63
- $this->cpts = new rtbCustomPostTypes();
64
-
65
- // Add the admin menu
66
- add_action( 'admin_menu', array( $this, 'add_menu_page' ) );
67
-
68
- // Flush the rewrite rules for the custom post types
69
- register_activation_hook( __FILE__, array( $this, 'rewrite_flush' ) );
70
-
71
- // Load the template functions which print the booking form, etc
72
- require_once( RTB_PLUGIN_DIR . '/includes/template-functions.php' );
73
-
74
- // Load assets
75
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
76
- add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
77
-
78
- // Handle notifications
79
- require_once( RTB_PLUGIN_DIR . '/includes/Notifications.class.php' );
80
- $this->notifications = new rtbNotifications();
81
-
82
- // Load settings
83
- require_once( RTB_PLUGIN_DIR . '/includes/Settings.class.php' );
84
- $this->settings = new rtbSettings();
85
-
86
- // Append booking form to a post's $content variable
87
- add_filter( 'the_content', array( $this, 'append_to_content' ) );
88
-
89
- // Register the widget
90
- add_action( 'widgets_init', array( $this, 'register_widgets' ) );
91
-
92
- // Add links to plugin listing
93
- add_filter('plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
94
-
95
- }
96
-
97
- /**
98
- * Flush the rewrite rules when this plugin is activated to update with
99
- * custom post types
100
- * @since 0.0.1
101
- */
102
- public function rewrite_flush() {
103
- $this->cpts->load_cpts();
104
- flush_rewrite_rules();
105
- }
106
-
107
- /**
108
- * Load the plugin textdomain for localistion
109
- * @since 0.0.1
110
- */
111
- public function load_textdomain() {
112
- load_plugin_textdomain( RTB_TEXTDOMAIN, false, plugin_basename( dirname( __FILE__ ) ) . "/languages" );
113
- }
114
-
115
- /**
116
- * Add a role to manage the bookings and add the capability to Editors,
117
- * Administrators and Super Admins
118
- * @since 0.0.1
119
- */
120
- public function add_roles() {
121
-
122
- // The booking manager should be able to access the bookings list and
123
- // update booking statuses, but shouldn't be able to touch anything else
124
- // in the account.
125
- $booking_manager = add_role(
126
- 'rtb_booking_manager',
127
- __( 'Booking Manager', RTB_TEXTDOMAIN ),
128
- array(
129
- 'read' => true,
130
- 'manage_bookings' => true,
131
- )
132
- );
133
-
134
- $manage_bookings_roles = apply_filters(
135
- 'rtb_manage_bookings_roles',
136
- array(
137
- 'administrator',
138
- 'editor',
139
- )
140
- );
141
-
142
- global $wp_roles;
143
- foreach ( $manage_bookings_roles as $role ) {
144
- $wp_roles->add_cap( $role, 'manage_bookings' );
145
- }
146
- }
147
-
148
- /**
149
- * Add the top-level admin menu page
150
- * @since 0.0.1
151
- */
152
- public function add_menu_page() {
153
-
154
- add_menu_page(
155
- _x( 'Bookings', 'Title of admin page that lists bookings', RTB_TEXTDOMAIN ),
156
- _x( 'Bookings', 'Title of bookings admin menu item', RTB_TEXTDOMAIN ),
157
- 'manage_bookings',
158
- 'rtb-bookings',
159
- array( $this, 'show_admin_bookings_page' ),
160
- 'dashicons-calendar',
161
- '26.2987'
162
- );
163
-
164
- }
165
-
166
- /**
167
- * Display the admin bookings page
168
- * @since 0.0.1
169
- */
170
- public function show_admin_bookings_page() {
171
-
172
- require_once( RTB_PLUGIN_DIR . '/includes/WP_List_Table.BookingsTable.class.php' );
173
- $bookings_table = new rtbBookingsTable();
174
- $bookings_table->prepare_items();
175
- ?>
176
-
177
- <div class="wrap">
178
- <h2><?php _e( 'Restaurant Bookings', RTB_TEXTDOMAIN ); ?></h2>
179
- <?php do_action( 'rtb_bookings_table_top' ); ?>
180
- <form id="rtb-bookings-table" method="POST" action="">
181
- <input type="hidden" name="post_type" value="<?php echo RTB_BOOKING_POST_TYPE; ?>" />
182
- <input type="hidden" name="page" value="rtb-bookings">
183
-
184
- <?php $bookings_table->views(); ?>
185
- <?php $bookings_table->advanced_filters(); ?>
186
- <?php $bookings_table->display(); ?>
187
- </form>
188
- <?php do_action( 'rtb_bookings_table_btm' ); ?>
189
- </div>
190
-
191
- <?php
192
- }
193
-
194
- /**
195
- * Append booking form to a post's $content variable
196
- * @since 0.0.1
197
- */
198
- function append_to_content( $content ) {
199
-
200
- if ( !is_main_query() || !in_the_loop() ) {
201
- return $content;
202
- }
203
-
204
- $booking_page = $this->settings->get_setting( 'booking-page' );
205
- if ( empty( $booking_page ) ) {
206
- return $content;
207
- }
208
-
209
- global $post;
210
- if ( $post->ID !== $this->settings->get_setting( 'booking-page' ) ) {
211
- return $content;
212
- }
213
-
214
- return $content . rtb_print_booking_form();
215
- }
216
-
217
- /**
218
- * Enqueue the admin-only CSS and Javascript
219
- * @since 0.0.1
220
- */
221
- public function enqueue_admin_assets() {
222
-
223
- $screen = get_current_screen();
224
- if ( $screen->base == 'toplevel_page_rtb-bookings' || $screen->base == 'bookings_page_rtb-settings' ) {
225
- wp_enqueue_style( 'rtb-admin', RTB_PLUGIN_URL . '/assets/css/admin.css' );
226
- wp_enqueue_script( 'rtb-admin', RTB_PLUGIN_URL . '/assets/js/admin.js', array( 'jquery' ), '', true );
227
- }
228
- }
229
-
230
- /**
231
- * Register the front-end CSS and Javascript for the booking form
232
- * @since 0.0.1
233
- */
234
- function register_assets() {
235
-
236
- if ( !RTB_LOAD_FRONTEND_ASSETS ) {
237
- return;
238
- }
239
-
240
- wp_register_style( 'pickadate-default', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.css' );
241
- wp_register_style( 'pickadate-date', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.date.css' );
242
- wp_register_style( 'pickadate-time', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.time.css' );
243
- wp_register_script( 'pickadate', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.js', array( 'jquery' ), '', true );
244
- wp_register_script( 'pickadate-date', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.date.js', array( 'jquery' ), '', true );
245
- wp_register_script( 'pickadate-time', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.time.js', array( 'jquery' ), '', true );
246
- wp_register_script( 'pickadate-legacy', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/legacy.js', array( 'jquery' ), '', true );
247
-
248
- $i8n = $this->settings->get_setting( 'i8n' );
249
- if ( !empty( $i8n ) ) {
250
- wp_register_script( 'pickadate-i8n', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/translations/' . esc_attr( $i8n ) . '.js', array( 'jquery' ), '', true );
251
-
252
- // Arabic and Hebrew are right-to-left languages
253
- if ( $i8n == 'ar' || $i8n == 'he_IL' ) {
254
- wp_register_style( 'pickadate-rtl', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/rtl.css' );
255
- }
256
- }
257
-
258
- wp_register_style( 'rtb-booking-form', RTB_PLUGIN_URL . '/assets/css/booking-form.css' );
259
- wp_register_script( 'rtb-booking-form', RTB_PLUGIN_URL . '/assets/js/booking-form.js', array( 'jquery' ) );
260
- }
261
-
262
- /**
263
- * Register the widgets
264
- * @since 0.0.1
265
- */
266
- public function register_widgets() {
267
- require_once( RTB_PLUGIN_DIR . '/includes/WP_Widget.BookingFormWidget.class.php' );
268
- register_widget( 'rtbBookingFormWidget' );
269
- }
270
-
271
- /**
272
- * Add links to the plugin listing on the installed plugins page
273
- * @since 0.0.1
274
- */
275
- public function plugin_action_links( $links, $plugin ) {
276
-
277
- if ( $plugin == RTB_PLUGIN_FNAME ) {
278
-
279
- $links['help'] = '<a href="' . RTB_PLUGIN_URL . '/docs" title="' . __( 'View the help documentation for Restaurant Reservations', RTB_TEXTDOMAIN ) . '">' . __( 'Help', RTB_TEXTDOMAIN ) . '</a>';
280
- }
281
-
282
- return $links;
283
-
284
- }
285
-
286
- }
287
- } // endif;
288
-
289
  $rtb_controller = new rtbInit();
1
+ <?php
2
+ /**
3
+ * Plugin Name: Restaurant Reservations
4
+ * Plugin URI: http://themeofthecrop.com
5
+ * Description: Accept restaurant reservations and bookings online.
6
+ * Version: 1.1.3
7
+ * Author: Theme of the Crop
8
+ * Author URI: http://themeofthecrop.com
9
+ * License: GNU General Public License v2.0 or later
10
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
+ * Requires at least: 3.8
12
+ * Tested up to: 3.9.1
13
+ *
14
+ * Text Domain: rtbdomain
15
+ * Domain Path: /languages/
16
+ *
17
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
18
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
19
+ * or (at your option) any later version.
20
+ *
21
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
22
+ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
+ *
24
+ * You should have received a copy of the GNU General Public License along with this program; if not, write
25
+ * to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
+ */
27
+ if ( ! defined( 'ABSPATH' ) )
28
+ exit;
29
+
30
+ if ( !class_exists( 'rtbInit' ) ) {
31
+ class rtbInit {
32
+
33
+ /**
34
+ * Set a flag which tracks whether the form has already been rendered on
35
+ * the page. Only one form per page for now.
36
+ * @todo support multiple forms per page
37
+ */
38
+ public $form_rendered = false;
39
+
40
+ /**
41
+ * Initialize the plugin and register hooks
42
+ */
43
+ public function __construct() {
44
+
45
+ // Common strings
46
+ define( 'RTB_TEXTDOMAIN', 'rtbdomain' );
47
+ define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
48
+ define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
49
+ define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
50
+ define( 'RTB_BOOKING_POST_TYPE', 'rtb-booking' );
51
+ define( 'RTB_BOOKING_POST_TYPE_SLUG', 'booking' );
52
+ define( 'RTB_LOAD_FRONTEND_ASSETS', apply_filters( 'rtb-load-frontend-assets', true ) );
53
+
54
+
55
+ // Initialize the plugin
56
+ add_action( 'init', array( $this, 'load_textdomain' ) );
57
+
58
+ // Add custom roles and capabilities
59
+ add_action( 'init', array( $this, 'add_roles' ) );
60
+
61
+ // Load custom post types
62
+ require_once( RTB_PLUGIN_DIR . '/includes/CustomPostTypes.class.php' );
63
+ $this->cpts = new rtbCustomPostTypes();
64
+
65
+ // Add the admin menu
66
+ add_action( 'admin_menu', array( $this, 'add_menu_page' ) );
67
+
68
+ // Flush the rewrite rules for the custom post types
69
+ register_activation_hook( __FILE__, array( $this, 'rewrite_flush' ) );
70
+
71
+ // Load the template functions which print the booking form, etc
72
+ require_once( RTB_PLUGIN_DIR . '/includes/template-functions.php' );
73
+
74
+ // Load assets
75
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_assets' ) );
76
+ add_action( 'wp_enqueue_scripts', array( $this, 'register_assets' ) );
77
+
78
+ // Handle notifications
79
+ require_once( RTB_PLUGIN_DIR . '/includes/Notifications.class.php' );
80
+ $this->notifications = new rtbNotifications();
81
+
82
+ // Load settings
83
+ require_once( RTB_PLUGIN_DIR . '/includes/Settings.class.php' );
84
+ $this->settings = new rtbSettings();
85
+
86
+ // Append booking form to a post's $content variable
87
+ add_filter( 'the_content', array( $this, 'append_to_content' ) );
88
+
89
+ // Register the widget
90
+ add_action( 'widgets_init', array( $this, 'register_widgets' ) );
91
+
92
+ // Add links to plugin listing
93
+ add_filter('plugin_action_links', array( $this, 'plugin_action_links' ), 10, 2);
94
+
95
+ }
96
+
97
+ /**
98
+ * Flush the rewrite rules when this plugin is activated to update with
99
+ * custom post types
100
+ * @since 0.0.1
101
+ */
102
+ public function rewrite_flush() {
103
+ $this->cpts->load_cpts();
104
+ flush_rewrite_rules();
105
+ }
106
+
107
+ /**
108
+ * Load the plugin textdomain for localistion
109
+ * @since 0.0.1
110
+ */
111
+ public function load_textdomain() {
112
+ load_plugin_textdomain( RTB_TEXTDOMAIN, false, plugin_basename( dirname( __FILE__ ) ) . "/languages" );
113
+ }
114
+
115
+ /**
116
+ * Add a role to manage the bookings and add the capability to Editors,
117
+ * Administrators and Super Admins
118
+ * @since 0.0.1
119
+ */
120
+ public function add_roles() {
121
+
122
+ // The booking manager should be able to access the bookings list and
123
+ // update booking statuses, but shouldn't be able to touch anything else
124
+ // in the account.
125
+ $booking_manager = add_role(
126
+ 'rtb_booking_manager',
127
+ __( 'Booking Manager', RTB_TEXTDOMAIN ),
128
+ array(
129
+ 'read' => true,
130
+ 'manage_bookings' => true,
131
+ )
132
+ );
133
+
134
+ $manage_bookings_roles = apply_filters(
135
+ 'rtb_manage_bookings_roles',
136
+ array(
137
+ 'administrator',
138
+ 'editor',
139
+ )
140
+ );
141
+
142
+ global $wp_roles;
143
+ foreach ( $manage_bookings_roles as $role ) {
144
+ $wp_roles->add_cap( $role, 'manage_bookings' );
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Add the top-level admin menu page
150
+ * @since 0.0.1
151
+ */
152
+ public function add_menu_page() {
153
+
154
+ add_menu_page(
155
+ _x( 'Bookings', 'Title of admin page that lists bookings', RTB_TEXTDOMAIN ),
156
+ _x( 'Bookings', 'Title of bookings admin menu item', RTB_TEXTDOMAIN ),
157
+ 'manage_bookings',
158
+ 'rtb-bookings',
159
+ array( $this, 'show_admin_bookings_page' ),
160
+ 'dashicons-calendar',
161
+ '26.2987'
162
+ );
163
+
164
+ }
165
+
166
+ /**
167
+ * Display the admin bookings page
168
+ * @since 0.0.1
169
+ */
170
+ public function show_admin_bookings_page() {
171
+
172
+ require_once( RTB_PLUGIN_DIR . '/includes/WP_List_Table.BookingsTable.class.php' );
173
+ $bookings_table = new rtbBookingsTable();
174
+ $bookings_table->prepare_items();
175
+ ?>
176
+
177
+ <div class="wrap">
178
+ <h2><?php _e( 'Restaurant Bookings', RTB_TEXTDOMAIN ); ?></h2>
179
+ <?php do_action( 'rtb_bookings_table_top' ); ?>
180
+ <form id="rtb-bookings-table" method="POST" action="">
181
+ <input type="hidden" name="post_type" value="<?php echo RTB_BOOKING_POST_TYPE; ?>" />
182
+ <input type="hidden" name="page" value="rtb-bookings">
183
+
184
+ <?php $bookings_table->views(); ?>
185
+ <?php $bookings_table->advanced_filters(); ?>
186
+ <?php $bookings_table->display(); ?>
187
+ </form>
188
+ <?php do_action( 'rtb_bookings_table_btm' ); ?>
189
+ </div>
190
+
191
+ <?php
192
+ }
193
+
194
+ /**
195
+ * Append booking form to a post's $content variable
196
+ * @since 0.0.1
197
+ */
198
+ function append_to_content( $content ) {
199
+
200
+ if ( !is_main_query() || !in_the_loop() ) {
201
+ return $content;
202
+ }
203
+
204
+ $booking_page = $this->settings->get_setting( 'booking-page' );
205
+ if ( empty( $booking_page ) ) {
206
+ return $content;
207
+ }
208
+
209
+ global $post;
210
+ if ( $post->ID !== $this->settings->get_setting( 'booking-page' ) ) {
211
+ return $content;
212
+ }
213
+
214
+ return $content . rtb_print_booking_form();
215
+ }
216
+
217
+ /**
218
+ * Enqueue the admin-only CSS and Javascript
219
+ * @since 0.0.1
220
+ */
221
+ public function enqueue_admin_assets() {
222
+
223
+ $screen = get_current_screen();
224
+ if ( $screen->base == 'toplevel_page_rtb-bookings' || $screen->base == 'bookings_page_rtb-settings' ) {
225
+ wp_enqueue_style( 'rtb-admin', RTB_PLUGIN_URL . '/assets/css/admin.css' );
226
+ wp_enqueue_script( 'rtb-admin', RTB_PLUGIN_URL . '/assets/js/admin.js', array( 'jquery' ), '', true );
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Register the front-end CSS and Javascript for the booking form
232
+ * @since 0.0.1
233
+ */
234
+ function register_assets() {
235
+
236
+ if ( !RTB_LOAD_FRONTEND_ASSETS ) {
237
+ return;
238
+ }
239
+
240
+ wp_register_style( 'pickadate-default', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.css' );
241
+ wp_register_style( 'pickadate-date', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.date.css' );
242
+ wp_register_style( 'pickadate-time', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/default.time.css' );
243
+ wp_register_script( 'pickadate', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.js', array( 'jquery' ), '', true );
244
+ wp_register_script( 'pickadate-date', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.date.js', array( 'jquery' ), '', true );
245
+ wp_register_script( 'pickadate-time', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/picker.time.js', array( 'jquery' ), '', true );
246
+ wp_register_script( 'pickadate-legacy', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/legacy.js', array( 'jquery' ), '', true );
247
+
248
+ $i8n = $this->settings->get_setting( 'i8n' );
249
+ if ( !empty( $i8n ) ) {
250
+ wp_register_script( 'pickadate-i8n', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/translations/' . esc_attr( $i8n ) . '.js', array( 'jquery' ), '', true );
251
+
252
+ // Arabic and Hebrew are right-to-left languages
253
+ if ( $i8n == 'ar' || $i8n == 'he_IL' ) {
254
+ wp_register_style( 'pickadate-rtl', RTB_PLUGIN_URL . '/lib/simple-admin-pages/lib/pickadate/themes/rtl.css' );
255
+ }
256
+ }
257
+
258
+ wp_register_style( 'rtb-booking-form', RTB_PLUGIN_URL . '/assets/css/booking-form.css' );
259
+ wp_register_script( 'rtb-booking-form', RTB_PLUGIN_URL . '/assets/js/booking-form.js', array( 'jquery' ) );
260
+ }
261
+
262
+ /**
263
+ * Register the widgets
264
+ * @since 0.0.1
265
+ */
266
+ public function register_widgets() {
267
+ require_once( RTB_PLUGIN_DIR . '/includes/WP_Widget.BookingFormWidget.class.php' );
268
+ register_widget( 'rtbBookingFormWidget' );
269
+ }
270
+
271
+ /**
272
+ * Add links to the plugin listing on the installed plugins page
273
+ * @since 0.0.1
274
+ */
275
+ public function plugin_action_links( $links, $plugin ) {
276
+
277
+ if ( $plugin == RTB_PLUGIN_FNAME ) {
278
+
279
+ $links['help'] = '<a href="' . RTB_PLUGIN_URL . '/docs" title="' . __( 'View the help documentation for Restaurant Reservations', RTB_TEXTDOMAIN ) . '">' . __( 'Help', RTB_TEXTDOMAIN ) . '</a>';
280
+ }
281
+
282
+ return $links;
283
+
284
+ }
285
+
286
+ }
287
+ } // endif;
288
+
289
  $rtb_controller = new rtbInit();