Restaurant Reservations - Version 1.8

Version Description

Download this release

Release Info

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

Code changes from version 1.7.8 to 1.8

Gruntfile.js CHANGED
@@ -10,7 +10,7 @@ module.exports = function(grunt) {
10
// Configure JSHint
11
jshint: {
12
test: {
13
- src: 'assets/js/*.js'
14
}
15
},
16
@@ -66,6 +66,6 @@ module.exports = function(grunt) {
66
// Default task(s).
67
grunt.registerTask('default', ['watch']);
68
grunt.registerTask('build', ['jshint']);
69
- grunt.registerTask('package', ['build', 'compress']);
70
71
};
10
// Configure JSHint
11
jshint: {
12
test: {
13
+ src: ['assets/js/*.js', '!assets/js/block-booking-form.js', '!assets/js/blocks.build.js']
14
}
15
},
16
66
// Default task(s).
67
grunt.registerTask('default', ['watch']);
68
grunt.registerTask('build', ['jshint']);
69
+ grunt.registerTask('package', ['build', 'makepot', 'compress']);
70
71
};
assets/js/block-booking-form.js ADDED
@@ -0,0 +1,48 @@
1
+ const { __ } = wp.i18n;
2
+ const { registerBlockType } = wp.blocks;
3
+ const { SelectControl, PanelBody, ServerSideRender, Disabled } = wp.components;
4
+ const { InspectorControls } = wp.editor;
5
+ const { locationsEnabled, locations } = rtb_blocks;
6
+
7
+ registerBlockType( 'restaurant-reservations/booking-form', {
8
+ title: __( 'Booking Form', 'restaurant-reservations' ),
9
+ icon: 'calendar',
10
+ category: 'widgets',
11
+ attributes: {
12
+ location: {
13
+ type: 'number',
14
+ default: 0
15
+ }
16
+ },
17
+ supports: {
18
+ html: false,
19
+ reusable: false,
20
+ multiple: false,
21
+ },
22
+ edit( { attributes, setAttributes } ) {
23
+ const { location } = attributes;
24
+
25
+ return (
26
+ <div>
27
+ {locationsEnabled ? (
28
+ <InspectorControls>
29
+ <PanelBody>
30
+ <SelectControl
31
+ label={ __( 'Location' ) }
32
+ value={ location }
33
+ onChange={ ( location ) => setAttributes( { location } ) }
34
+ options={ locations }
35
+ />
36
+ </PanelBody>
37
+ </InspectorControls>
38
+ ) : '' }
39
+ <Disabled>
40
+ <ServerSideRender block="restaurant-reservations/booking-form" attributes={ attributes } />
41
+ </Disabled>
42
+ </div>
43
+ );
44
+ },
45
+ save() {
46
+ return null;
47
+ },
48
+ } );
assets/js/blocks.build.js ADDED
@@ -0,0 +1 @@
1
+ !function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t){var n=wp.i18n.__,r=wp.blocks.registerBlockType,o=wp.components,l=o.SelectControl,a=o.PanelBody,i=o.ServerSideRender,u=o.Disabled,c=wp.editor.InspectorControls,s=rtb_blocks,p=s.locationsEnabled,m=s.locations;r("restaurant-reservations/booking-form",{title:n("Booking Form","restaurant-reservations"),icon:"calendar",category:"widgets",attributes:{location:{type:"number",default:0}},supports:{html:!1,reusable:!1,multiple:!1},edit:function(e){var t=e.attributes,r=e.setAttributes,o=t.location;return wp.element.createElement("div",null,p?wp.element.createElement(c,null,wp.element.createElement(a,null,wp.element.createElement(l,{label:n("Location"),value:o,onChange:function(e){return r({location:e})},options:m}))):"",wp.element.createElement(u,null,wp.element.createElement(i,{block:"restaurant-reservations/booking-form",attributes:t})))},save:function(){return null}})}]);
includes/Blocks.class.php ADDED
@@ -0,0 +1,83 @@
1
+ <?php
2
+ if ( !defined( 'ABSPATH' ) ) exit;
3
+
4
+ if ( !class_exists( 'rtbBlocks' ) ) {
5
+ /**
6
+ * Class to create, edit and display blocks for the Gutenberg editor
7
+ *
8
+ * @since 0.0.1
9
+ */
10
+ class rtbBlocks {
11
+
12
+ /**
13
+ * Add hooks
14
+ */
15
+ public function __construct() {
16
+ add_action( 'init', array( $this, 'register' ) );
17
+ }
18
+
19
+ /**
20
+ * Register blocks
21
+ */
22
+ public function register() {
23
+
24
+ if ( !function_exists( 'register_block_type' ) ) {
25
+ return;
26
+ }
27
+
28
+ global $rtb_controller;
29
+
30
+ $rtb_controller->register_assets();
31
+
32
+ wp_register_script(
33
+ 'restaurant-reservations-blocks',
34
+ RTB_PLUGIN_URL . '/assets/js/blocks.build.js',
35
+ array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' )
36
+ );
37
+
38
+ register_block_type( 'restaurant-reservations/booking-form', array(
39
+ 'editor_script' => 'restaurant-reservations-blocks',
40
+ 'editor_style' => 'rtb-booking-form',
41
+ 'render_callback' => 'rtb_print_booking_form',
42
+ 'attributes' => array(
43
+ 'location' => array(
44
+ 'type' => 'number',
45
+ 'default' => 0,
46
+ ),
47
+ ),
48
+ ) );
49
+
50
+ add_action( 'admin_init', array( $this, 'register_admin' ) );
51
+ }
52
+
53
+ /**
54
+ * Register admin-only assets for block handling
55
+ */
56
+ public function register_admin() {
57
+
58
+ global $rtb_controller;
59
+
60
+ $locations_enabled = !!$rtb_controller->locations->post_type;
61
+
62
+ $location_options = array( array( 'value' => 0, 'label' => __('Ask the customer to select a location', 'restaurant-reservations' ) ) );
63
+ if ($locations_enabled) {
64
+ $locations = $rtb_controller->locations->get_location_options();
65
+ foreach ( $locations as $id => $name ) {
66
+ $location_options[] = array( 'value' => $id, 'label' => $name);
67
+ }
68
+ }
69
+
70
+ wp_add_inline_script(
71
+ 'restaurant-reservations-blocks',
72
+ sprintf(
73
+ 'var rtb_blocks = %s;',
74
+ json_encode( array(
75
+ 'locationsEnabled' => $locations_enabled,
76
+ 'locations' => $location_options,
77
+ ) )
78
+ ),
79
+ 'before'
80
+ );
81
+ }
82
+ }
83
+ } // endif
includes/MultipleLocations.class.php CHANGED
@@ -539,7 +539,7 @@ if ( ! class_exists( 'rtbMultipleLocations', false ) ) {
539
<div class="rtb-location-meta-input rtb-location-meta-append-form">
540
<label>
541
<input type="checkbox" name="rtb_append_booking_form" value="1"<?php if ( $append_booking_form ) : ?> checked="checked"<?php endif; ?>>
542
- <?php esc_html_e( 'Show booking form with this location.', 'restaurant-reservations' ); ?>
543
</label>
544
</div>
545
539
<div class="rtb-location-meta-input rtb-location-meta-append-form">
540
<label>
541
<input type="checkbox" name="rtb_append_booking_form" value="1"<?php if ( $append_booking_form ) : ?> checked="checked"<?php endif; ?>>
542
+ <?php esc_html_e( "Automatically add the booking form to this page.", 'restaurant-reservations' ); ?>
543
</label>
544
</div>
545
includes/template-functions.php CHANGED
@@ -110,13 +110,13 @@ function rtb_print_booking_form( $args = array() ) {
110
<?php
111
foreach( $contents['fields'] as $slug => $field ) {
112
113
- $args = empty( $field['callback_args'] ) ? array() : $field['callback_args'];
114
115
if ( !empty( $field['required'] ) ) {
116
- $args = array_merge( $args, array( 'required' => $field['required'] ) );
117
}
118
119
- call_user_func( $field['callback'], $slug, $field['title'], $field['request_input'], $args );
120
}
121
?>
122
</fieldset>
110
<?php
111
foreach( $contents['fields'] as $slug => $field ) {
112
113
+ $callback_args = empty( $field['callback_args'] ) ? array() : $field['callback_args'];
114
115
if ( !empty( $field['required'] ) ) {
116
+ $callback_args = array_merge( $callback_args, array( 'required' => $field['required'] ) );
117
}
118
119
+ call_user_func( $field['callback'], $slug, $field['title'], $field['request_input'], $callback_args );
120
}
121
?>
122
</fieldset>
languages/restaurant-reservations.pot CHANGED
@@ -2,9 +2,9 @@
2
# This file is distributed under the GNU General Public License v2.0 or later.
3
msgid ""
4
msgstr ""
5
- "Project-Id-Version: Restaurant Reservations 1.7.8\n"
6
"Report-Msgid-Bugs-To: https://themeofthecrop.com\n"
7
- "POT-Creation-Date: 2018-09-13 10:09:44+00:00\n"
8
"MIME-Version: 1.0\n"
9
"Content-Type: text/plain; charset=utf-8\n"
10
"Content-Transfer-Encoding: 8bit\n"
@@ -194,7 +194,7 @@ msgstr ""
194
msgid "Columns"
195
msgstr ""
196
197
- #: includes/AdminBookings.class.php:167 restaurant-reservations.php:231
198
msgid "Add Booking"
199
msgstr ""
200
@@ -314,6 +314,10 @@ msgstr ""
314
msgid "Invalid"
315
msgstr ""
316
317
#: includes/Booking.class.php:194
318
msgid "Please enter the date you would like to book."
319
msgstr ""
@@ -423,7 +427,7 @@ msgstr ""
423
msgid "Add New Booking"
424
msgstr ""
425
426
- #: includes/CustomPostTypes.class.php:52 restaurant-reservations.php:232
427
msgid "Edit Booking"
428
msgstr ""
429
@@ -510,7 +514,7 @@ msgid "Reservations"
510
msgstr ""
511
512
#: includes/MultipleLocations.class.php:542
513
- msgid "Show booking form with this location."
514
msgstr ""
515
516
#: includes/MultipleLocations.class.php:548 includes/Settings.class.php:635
@@ -1358,21 +1362,21 @@ msgstr ""
1358
msgid "You do not have sufficient permissions to access this page."
1359
msgstr ""
1360
1361
- #: restaurant-reservations.php:160
1362
msgid "Booking Manager"
1363
msgstr ""
1364
1365
- #: restaurant-reservations.php:233
1366
msgid ""
1367
"An unspecified error occurred. Please try again. If the problem persists, "
1368
"try logging out and logging back in."
1369
msgstr ""
1370
1371
- #: restaurant-reservations.php:297
1372
msgid "View the help documentation for Restaurant Reservations"
1373
msgstr ""
1374
1375
- #: restaurant-reservations.php:297
1376
msgid "Help"
1377
msgstr ""
1378
2
# This file is distributed under the GNU General Public License v2.0 or later.
3
msgid ""
4
msgstr ""
5
+ "Project-Id-Version: Restaurant Reservations 1.8.0\n"
6
"Report-Msgid-Bugs-To: https://themeofthecrop.com\n"
7
+ "POT-Creation-Date: 2018-12-11 17:49:49+00:00\n"
8
"MIME-Version: 1.0\n"
9
"Content-Type: text/plain; charset=utf-8\n"
10
"Content-Transfer-Encoding: 8bit\n"
194
msgid "Columns"
195
msgstr ""
196
197
+ #: includes/AdminBookings.class.php:167 restaurant-reservations.php:235
198
msgid "Add Booking"
199
msgstr ""
200
314
msgid "Invalid"
315
msgstr ""
316
317
+ #: includes/Blocks.class.php:62
318
+ msgid "Ask the customer to select a location"
319
+ msgstr ""
320
+
321
#: includes/Booking.class.php:194
322
msgid "Please enter the date you would like to book."
323
msgstr ""
427
msgid "Add New Booking"
428
msgstr ""
429
430
+ #: includes/CustomPostTypes.class.php:52 restaurant-reservations.php:236
431
msgid "Edit Booking"
432
msgstr ""
433
514
msgstr ""
515
516
#: includes/MultipleLocations.class.php:542
517
+ msgid "Automatically add the booking form to this page."
518
msgstr ""
519
520
#: includes/MultipleLocations.class.php:548 includes/Settings.class.php:635
1362
msgid "You do not have sufficient permissions to access this page."
1363
msgstr ""
1364
1365
+ #: restaurant-reservations.php:164
1366
msgid "Booking Manager"
1367
msgstr ""
1368
1369
+ #: restaurant-reservations.php:237
1370
msgid ""
1371
"An unspecified error occurred. Please try again. If the problem persists, "
1372
"try logging out and logging back in."
1373
msgstr ""
1374
1375
+ #: restaurant-reservations.php:301
1376
msgid "View the help documentation for Restaurant Reservations"
1377
msgstr ""
1378
1379
+ #: restaurant-reservations.php:301
1380
msgid "Help"
1381
msgstr ""
1382
package.json CHANGED
@@ -1,16 +1,26 @@
1
{
2
"name": "restaurant-reservations",
3
"description": "Accept restaurant reservations and bookings online.",
4
- "version": "1.7.8",
5
"author": {
6
"name": "Theme of the Crop",
7
"url": "https://themeofthecrop.com"
8
},
9
"devDependencies": {
10
"grunt": "~1.0.0",
11
"grunt-contrib-compress": "~1.3.0",
12
"grunt-contrib-jshint": "~1.0.0",
13
"grunt-contrib-watch": "~1.0.0",
14
- "grunt-wp-i18n": "~0.5.4"
15
}
16
}
1
{
2
"name": "restaurant-reservations",
3
"description": "Accept restaurant reservations and bookings online.",
4
+ "version": "1.8.0",
5
"author": {
6
"name": "Theme of the Crop",
7
"url": "https://themeofthecrop.com"
8
},
9
+ "scripts": {
10
+ "build": "cross-env BABEL_ENV=default NODE_ENV=production webpack",
11
+ "dev": "cross-env BABEL_ENV=default webpack --watch"
12
+ },
13
"devDependencies": {
14
+ "babel-core": "^6.25.0",
15
+ "babel-loader": "^7.1.1",
16
+ "babel-plugin-transform-react-jsx": "^6.24.1",
17
+ "babel-preset-env": "^1.6.0",
18
+ "cross-env": "^5.0.1",
19
"grunt": "~1.0.0",
20
"grunt-contrib-compress": "~1.3.0",
21
"grunt-contrib-jshint": "~1.0.0",
22
"grunt-contrib-watch": "~1.0.0",
23
+ "grunt-wp-i18n": "~0.5.4",
24
+ "webpack": "^3.1.0"
25
}
26
}
readme.md CHANGED
@@ -3,9 +3,9 @@ Contributors: NateWr
3
Author URI: https://github.com/NateWr
4
Plugin URL: https://themeofthecrop.com
5
Requires at Least: 4.4
6
- Tested Up To: 4.9.8
7
Tags: restaurant, reservations, bookings, table bookings, restaurant reservation, table reservation
8
- Stable tag: 1.7.8
9
License: GPLv2 or later
10
Donate link: https://themeofthecrop.com
11
@@ -27,7 +27,7 @@ Accept restaurant reservations and table bookings online. Quickly confirm or rej
27
* Send customers [an email](http://doc.themeofthecrop.com/plugins/restaurant-reservations/user/manage/send-emails) about their booking from the admin panel
28
* [Ban abusive customers](http://doc.themeofthecrop.com/plugins/restaurant-reservations/user/manage/ban-customers) to save money on no-shows
29
30
- [Theme of the Crop](https://themeofthecrop.com/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations) builds <a href="https://themeofthecrop.com/themes/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations" rel="friend">great WordPress restaurant themes</a> and plugins that help restaurants manage [responsive online menus](https://themeofthecrop.com/plugins/food-and-drink-menu/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations) and [boost their SEO](https://themeofthecrop.com/restaurant-seo/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations).
31
32
## How to use
33
@@ -119,6 +119,9 @@ Find answers to even more questions in the [FAQ](http://doc.themeofthecrop.com/p
119
120
## Changelog
121
122
#### 1.7.8 (2018-09-13)
123
- Add: #126 Setting to override the FROM header's email address
124
- Fix: #136 Preserve consent acquired state when booking is edited
3
Author URI: https://github.com/NateWr
4
Plugin URL: https://themeofthecrop.com
5
Requires at Least: 4.4
6
+ Tested Up To: 5.0
7
Tags: restaurant, reservations, bookings, table bookings, restaurant reservation, table reservation
8
+ Stable tag: 1.8
9
License: GPLv2 or later
10
Donate link: https://themeofthecrop.com
11
27
* Send customers [an email](http://doc.themeofthecrop.com/plugins/restaurant-reservations/user/manage/send-emails) about their booking from the admin panel
28
* [Ban abusive customers](http://doc.themeofthecrop.com/plugins/restaurant-reservations/user/manage/ban-customers) to save money on no-shows
29
30
+ [Theme of the Crop](https://themeofthecrop.com/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations) builds plugins that help restaurants manage [responsive online menus](https://themeofthecrop.com/plugins/food-and-drink-menu/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations) and [boost their SEO](https://themeofthecrop.com/restaurant-seo/?utm_source=Plugin&utm_medium=Plugin%20Description&utm_campaign=Restaurant%20Reservations).
31
32
## How to use
33
119
120
## Changelog
121
122
+ #### 1.8 (2018-12-11)
123
+ - Add: Gutenberg block for the booking form
124
+
125
#### 1.7.8 (2018-09-13)
126
- Add: #126 Setting to override the FROM header's email address
127
- Fix: #136 Preserve consent acquired state when booking is edited
restaurant-reservations.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: Restaurant Reservations
4
* Plugin URI: http://themeofthecrop.com
5
* Description: Accept restaurant reservations and bookings online.
6
- * Version: 1.7.8
7
* Author: Theme of the Crop
8
* Author URI: http://themeofthecrop.com
9
* License: GNU General Public License v2.0 or later
@@ -47,7 +47,7 @@ class rtbInit {
47
public function __construct() {
48
49
// Common strings
50
- define( 'RTB_VERSION', '1.7.8' );
51
define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
52
define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
53
define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
@@ -121,6 +121,10 @@ class rtbInit {
121
require_once( RTB_PLUGIN_DIR . '/includes/integrations/business-profile.php' );
122
require_once( RTB_PLUGIN_DIR . '/includes/integrations/woocommerce.php' );
123
124
// Load backwards compatibility functions
125
require_once( RTB_PLUGIN_DIR . '/includes/Compatibility.class.php' );
126
new rtbCompatibility();
3
* Plugin Name: Restaurant Reservations
4
* Plugin URI: http://themeofthecrop.com
5
* Description: Accept restaurant reservations and bookings online.
6
+ * Version: 1.8.0
7
* Author: Theme of the Crop
8
* Author URI: http://themeofthecrop.com
9
* License: GNU General Public License v2.0 or later
47
public function __construct() {
48
49
// Common strings
50
+ define( 'RTB_VERSION', '1.8.0' );
51
define( 'RTB_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
52
define( 'RTB_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );
53
define( 'RTB_PLUGIN_FNAME', plugin_basename( __FILE__ ) );
121
require_once( RTB_PLUGIN_DIR . '/includes/integrations/business-profile.php' );
122
require_once( RTB_PLUGIN_DIR . '/includes/integrations/woocommerce.php' );
123
124
+ // Load gutenberg blocks
125
+ require_once( RTB_PLUGIN_DIR . '/includes/Blocks.class.php' );
126
+ new rtbBlocks();
127
+
128
// Load backwards compatibility functions
129
require_once( RTB_PLUGIN_DIR . '/includes/Compatibility.class.php' );
130
new rtbCompatibility();
webpack.config.js ADDED
@@ -0,0 +1,29 @@
1
+ let webpack = require( 'webpack' ),
2
+ NODE_ENV = process.env.NODE_ENV || 'development',
3
+ webpackConfig = {
4
+ entry: './assets/js/block-booking-form.js',
5
+ output: {
6
+ path: __dirname,
7
+ filename: './assets/js/blocks.build.js',
8
+ },
9
+ module: {
10
+ loaders: [
11
+ {
12
+ test: /.js#x2F;,
13
+ loader: 'babel-loader',
14
+ exclude: /node_modules/,
15
+ },
16
+ ],
17
+ },
18
+ plugins: [
19
+ new webpack.DefinePlugin( {
20
+ 'process.env.NODE_ENV': JSON.stringify( NODE_ENV ),
21
+ } ),
22
+ ],
23
+ };
24
+
25
+ if ( 'production' === NODE_ENV ) {
26
+ webpackConfig.plugins.push( new webpack.optimize.UglifyJsPlugin() );
27
+ }
28
+
29
+ module.exports = webpackConfig;