WP Simple Booking Calendar - Version 1.5.5

Version Description

  • New: Added Gutenberg calendar block
Download this release

Release Info

Developer murgroland
Plugin Icon 128x128 WP Simple Booking Calendar
Version 1.5.5
Comparing to
See all releases

Code changes from version 1.5.1 to 1.5.5

blocks/sbc/assets/js/script-block-sbc.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var el = wp.element.createElement;
2
+ var ServerSideRender = wp.components.ServerSideRender;
3
+ var PanelBody = wp.components.PanelBody;
4
+ var SelectControl = wp.components.SelectControl;
5
+ var registerBlockType = wp.blocks.registerBlockType;
6
+ var InspectorControls = wp.editor.InspectorControls;
7
+ var __ = wp.i18n.__;
8
+
9
+ // Register the block
10
+ registerBlockType( 'wp-simple-booking-calendar/sbc', {
11
+
12
+ // The block's title
13
+ title : 'Single Calendar',
14
+
15
+ // The block's icon
16
+ icon : 'calendar-alt',
17
+
18
+ // The block category the block should be added to
19
+ category : 'wp-simple-booking-calendar',
20
+
21
+ // The block's attributes, needed to save the data
22
+ attributes : {
23
+
24
+ title : {
25
+ type : 'string'
26
+ }
27
+
28
+ },
29
+
30
+ edit : function( props ) {
31
+
32
+ return [
33
+
34
+ el( ServerSideRender, {
35
+ block : 'wp-simple-booking-calendar/sbc',
36
+ attributes : props.attributes
37
+ }),
38
+
39
+ el( InspectorControls, { key : 'inspector' },
40
+
41
+ el( PanelBody, {
42
+ title : __( 'Calendar Options', 'wp-simple-booking-calendar' ),
43
+ initialOpen : true
44
+ },
45
+
46
+ el( SelectControl, {
47
+
48
+ label : __( 'Display Calendar Title', 'wp-simple-booking-calendar' ),
49
+ value : props.attributes.title,
50
+ options : [
51
+ { value : 'yes', label : __( 'Yes', 'wp-simple-booking-calendar' ) },
52
+ { value : 'no', label : __( 'No', 'wp-simple-booking-calendar' ) }
53
+ ],
54
+ onChange : function( new_value ) {
55
+ props.setAttributes( { title : new_value } );
56
+ }
57
+ })
58
+
59
+ )
60
+
61
+ )
62
+
63
+ ];
64
+
65
+ },
66
+
67
+ save : function() {
68
+ return null;
69
+ }
70
+
71
+ });
blocks/sbc/functions.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Function that register the needed categories for the different block
8
+ * available in the plugin
9
+ *
10
+ */
11
+ if( ! function_exists( 'wpsbc_register_block_categories' ) ) {
12
+
13
+ function wpsbc_register_block_categories( $categories, $post ) {
14
+
15
+ /**
16
+ * Filter the post types where the blocks are available
17
+ *
18
+ * @param array
19
+ *
20
+ */
21
+ $post_types = apply_filters( 'wpsbc_register_block_categories_post_types', array( 'post', 'page' ) );
22
+
23
+ if( ! in_array( $post->post_type, $post_types ) )
24
+ return $categories;
25
+
26
+ $categories[] = array(
27
+ 'slug' => 'wp-simple-booking-calendar',
28
+ 'title' => 'WP Simple Booking Calendar',
29
+ 'icon' => ''
30
+ );
31
+
32
+ return $categories;
33
+
34
+ }
35
+ add_filter( 'block_categories', 'wpsbc_register_block_categories', 10, 2 );
36
+
37
+ }
38
+
39
+
40
+ /**
41
+ * Adds the front-end files to the admin editor screen
42
+ *
43
+ */
44
+ function wpsbc_add_front_end_scripts() {
45
+
46
+ if( ! function_exists( 'get_current_screen' ) )
47
+ return;
48
+
49
+ $screen = get_current_screen();
50
+
51
+ if( is_null( $screen ) )
52
+ return;
53
+
54
+ /**
55
+ * Filter the post types where the calendar media button should appear
56
+ *
57
+ * @param array
58
+ *
59
+ */
60
+ $post_types = apply_filters( 'wpsbc_register_block_categories_post_types', array( 'post', 'page' ) );
61
+
62
+ if( ! in_array( $screen->post_type, $post_types ) )
63
+ return;
64
+
65
+
66
+ // Enqueue front-end scripts on the admin part
67
+ wp_register_script( 'sbc-front-end-script', SBC_DIR_URL . 'js/sbc.js', array( 'jquery' ), SBC_VERSION, true );
68
+ wp_enqueue_script( 'sbc-front-end-script' );
69
+
70
+ // Enqueue front-end styles on the admin part
71
+ wp_register_style( 'sbc-front-end-style', SBC_DIR_URL . 'css/sbc.css', array(), SBC_VERSION );
72
+ wp_enqueue_style( 'sbc-front-end-style' );
73
+
74
+ }
75
+ add_action( 'admin_enqueue_scripts', 'wpsbc_add_front_end_scripts', 10 );
76
+
77
+
78
+ /**
79
+ * Registers the Single Calendar block
80
+ *
81
+ */
82
+ if( function_exists( 'register_block_type' ) ) {
83
+
84
+ function wpsbc_register_block_type_sbc() {
85
+
86
+ wp_register_script( 'sbc-script-block-sbc', SBC_DIR_URL . 'blocks/sbc/assets/js/script-block-sbc.js', array( 'wp-blocks', 'wp-element', 'wp-editor', 'wp-i18n' ) );
87
+
88
+ register_block_type(
89
+ 'wp-simple-booking-calendar/sbc',
90
+ array(
91
+ 'attributes' => array(
92
+ 'title' => array(
93
+ 'type' => 'string'
94
+ )
95
+ ),
96
+ 'editor_script' => 'sbc-script-block-sbc',
97
+ 'render_callback' => 'wpsbc_block_to_shortcode_sbc'
98
+ )
99
+ );
100
+
101
+ }
102
+ add_action( 'init', 'wpsbc_register_block_type_sbc' );
103
+
104
+ }
105
+
106
+
107
+ /**
108
+ * Render callback for the server render block
109
+ * Transforms the attributes from the blocks into the needed shortcode arguments
110
+ *
111
+ * @param array $args
112
+ *
113
+ * @return string
114
+ *
115
+ */
116
+ function wpsbc_block_to_shortcode_sbc( $args ) {
117
+
118
+ $atts = (array) $args;
119
+
120
+ // Validate booleans
121
+ $booleans = array('title');
122
+ foreach ($booleans as $key)
123
+ {
124
+ if (isset($atts[$key]))
125
+ {
126
+ // Replace string values: Yes = true, No = false
127
+ if (is_bool($atts[$key]) !== true)
128
+ {
129
+ $value = (strcasecmp($atts[$key], 'yes') == 0 || $atts[$key] == '1');
130
+ }
131
+ else
132
+ {
133
+ $value = $atts[$key];
134
+ }
135
+
136
+ $atts[$key] = $value;
137
+ }
138
+ }
139
+
140
+ // Process attributes
141
+ $defaults = array('id' => null, 'title' => true);
142
+ $values = shortcode_atts($defaults, $atts);
143
+
144
+ $model = new WpSimpleBookingCalendar_Model();
145
+ $view = new WpSimpleBookingCalendar_View();
146
+
147
+ return $view->setTemplate('shortcode/sbc')
148
+ ->assign('showTitle', $values['title'])
149
+ ->assign('calendar', $model->getCalendar())
150
+ ->fetch();
151
+
152
+ }
css/sbc-controller.css CHANGED
@@ -77,7 +77,7 @@ div.buy-full .box ul {list-style:none; padding-top:9px; display:block; height:52
77
 
78
  div.buy-full .box ul li {background: transparent url(../images/checked-icon.jpg) no-repeat left 6px; color:#666666; font-size:14px; padding:6px 0 5px 21px;}
79
  div.buy-full .box h2 {font-weight:normal; display:block; text-align:center; color:#0084ff; font-size:30px; float:left; margin:0 0 0 25px; padding:19px 0 0 0;}
80
- div.buy-full .box small {color:#0084ff; font-size:14px; display:block; margin:8px 0 0 6px; float:left;}
81
  div.buy-full .box span {display:block; height:50px; line-height:50px; text-align:center;}
82
  div.buy-full .box p {font-size:14px; color:#666666; padding:13px 20px 6px 20px;}
83
  div.buy-full .box strong {font-weight:normal; color:#0084ff;}
77
 
78
  div.buy-full .box ul li {background: transparent url(../images/checked-icon.jpg) no-repeat left 6px; color:#666666; font-size:14px; padding:6px 0 5px 21px;}
79
  div.buy-full .box h2 {font-weight:normal; display:block; text-align:center; color:#0084ff; font-size:30px; float:left; margin:0 0 0 25px; padding:19px 0 0 0;}
80
+ div.buy-full .box small {color:#0084ff; font-size:14px; display:block; margin:8px 0 0 6px; float:left; padding-top: 10px; }
81
  div.buy-full .box span {display:block; height:50px; line-height:50px; text-align:center;}
82
  div.buy-full .box p {font-size:14px; color:#666666; padding:13px 20px 6px 20px;}
83
  div.buy-full .box strong {font-weight:normal; color:#0084ff;}
library/WpSimpleBookingCalendar.php CHANGED
@@ -19,7 +19,7 @@ class WpSimpleBookingCalendar
19
  // Backend hooks and action callbacks
20
  if (is_admin())
21
  {
22
- add_action('admin_menu', create_function('', 'new WpSimpleBookingCalendar_Controller();'));
23
  }
24
  else
25
  {
@@ -31,12 +31,54 @@ class WpSimpleBookingCalendar
31
  }
32
 
33
  // Register shortcode
34
- add_action('init', create_function('', 'new WpSimpleBookingCalendar_Shortcode();'));
35
 
36
  // Register AJAX actions
37
- add_action('init', create_function('', 'new WpSimpleBookingCalendar_Ajax();'));
38
 
39
  // Register widget
40
- add_action('widgets_init', create_function('', 'return register_widget("WpSimpleBookingCalendar_Widget");'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
19
  // Backend hooks and action callbacks
20
  if (is_admin())
21
  {
22
+ add_action('admin_menu', array( __CLASS__, 'init_admin_menu' ) );
23
  }
24
  else
25
  {
31
  }
32
 
33
  // Register shortcode
34
+ add_action('init', array( __CLASS__, 'init_shortcode' ) );
35
 
36
  // Register AJAX actions
37
+ add_action('init', array( __CLASS__, 'init_ajax_actions' ) );
38
 
39
  // Register widget
40
+ add_action('widgets_init', array( __CLASS__, 'init_widgets' ) );
41
+
42
+ }
43
+
44
+ /**
45
+ * Initializes the admin menu
46
+ *
47
+ */
48
+ public static function init_admin_menu() {
49
+
50
+ new WpSimpleBookingCalendar_Controller();
51
+
52
+ }
53
+
54
+ /**
55
+ * Initializes the shortcode
56
+ *
57
+ */
58
+ public static function init_shortcode() {
59
+
60
+ new WpSimpleBookingCalendar_Shortcode();
61
+
62
  }
63
+
64
+ /**
65
+ * Initializes the ajax actions
66
+ *
67
+ */
68
+ public static function init_ajax_actions() {
69
+
70
+ new WpSimpleBookingCalendar_Ajax();
71
+
72
+ }
73
+
74
+ /**
75
+ * Initializes the widgets
76
+ *
77
+ */
78
+ public static function init_widgets() {
79
+
80
+ return register_widget( "WpSimpleBookingCalendar_Widget" );
81
+
82
+ }
83
+
84
  }
library/WpSimpleBookingCalendar/Shortcode.php CHANGED
@@ -32,8 +32,8 @@ class WpSimpleBookingCalendar_Shortcode
32
  public function registerMetabox()
33
  {
34
  // Metabox
35
- add_meta_box('sbc-metabox', __('Generate WP Simple Booking Calendar Token', 'sbc'), array($this, 'renderMetabox'), 'post', 'normal', 'high');
36
- add_meta_box('sbc-metabox', __('Generate WP Simple Booking Calendar Token', 'sbc'), array($this, 'renderMetabox'), 'page', 'normal', 'high');
37
 
38
  // Scripts & styles
39
  add_action('admin_print_scripts', array($this, 'enqueueMetaboxScripts'));
32
  public function registerMetabox()
33
  {
34
  // Metabox
35
+ add_meta_box('sbc-metabox', __( 'WP Simple Booking Calendar', 'sbc' ), array($this, 'renderMetabox'), 'post', 'normal', 'high');
36
+ add_meta_box('sbc-metabox', __( 'WP Simple Booking Calendar', 'sbc' ), array($this, 'renderMetabox'), 'page', 'normal', 'high');
37
 
38
  // Scripts & styles
39
  add_action('admin_print_scripts', array($this, 'enqueueMetaboxScripts'));
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === WP Simple Booking Calendar ===
2
- Contributors: simplebookingcalendar
3
  Tags: booking calendar, availability calendar, belegungsplan, bookings, calendar
4
  Requires at least: 3.0
5
- Tested up to: 4.9
6
- Stable tag: 1.5.1
7
 
8
  This booking calendar shows when something is booked or available. Use it to show when your holiday home is available for rent, for example.
9
 
@@ -95,6 +95,18 @@ Please check [wpsimplebookingcalendar.com](https://www.wpsimplebookingcalendar.c
95
 
96
  == Changelog ==
97
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  = 1.5.1 =
99
  * Fixed lowercase day abbreviations and month names
100
 
1
  === WP Simple Booking Calendar ===
2
+ Contributors: murgroland
3
  Tags: booking calendar, availability calendar, belegungsplan, bookings, calendar
4
  Requires at least: 3.0
5
+ Tested up to: 5.3
6
+ Stable tag: 1.5.5
7
 
8
  This booking calendar shows when something is booked or available. Use it to show when your holiday home is available for rent, for example.
9
 
95
 
96
  == Changelog ==
97
 
98
+ = 1.5.5 =
99
+ * New: Added Gutenberg calendar block
100
+
101
+ = 1.5.4 =
102
+ * Fixed: Removed PHP create_function deprecated function.
103
+
104
+ = 1.5.3 =
105
+ * Misc: Small interface change.
106
+
107
+ = 1.5.2 =
108
+ * Misc: Modified the way the WP Simple Booking Calendar post/page meta-box works, to be more clear to the user.
109
+
110
  = 1.5.1 =
111
  * Fixed lowercase day abbreviations and month names
112
 
views/controller/index.phtml CHANGED
@@ -45,7 +45,7 @@
45
  </table>
46
  <br />
47
  <div class="updated">
48
- <p style="font-size: 12px;">Paste the shortcode <strong>[sbc title="yes"]</strong> or <strong>[sbc title="no"]</strong> in a page or post to display the calendar on your website. Think you've found a bug? <a href="http://www.emailmeform.com/builder/form/mT37c0cufIwbQ4kJnCL" target="_blank">Click here</a> to report it.
49
  </p>
50
  </div>
51
  <div class="buy-full">
@@ -82,9 +82,9 @@
82
  <li>Responsive calendar themes</li>
83
  <li>Professional support</li>
84
  </ul>
85
- <span><h2>&dollar;29 </h2><small>one-time payment</small></span>
86
  <div class="bottom">
87
- <a href="http://www.wpsimplebookingcalendar.com/premium/" target="_blank" class="button">Read more</a>
88
  </div>
89
  <small class="bottom">100% money-back guarantee!</small>
90
  </div>
45
  </table>
46
  <br />
47
  <div class="updated">
48
+ <p style="font-size: 12px;">Paste the shortcode <strong>[sbc title="yes"]</strong> or <strong>[sbc title="no"]</strong> in a page or post to display the calendar on your website. Think you've found a bug? <a href="https://www.wpsimplebookingcalendar.com/contact/" target="_blank">Click here</a> to report it.
49
  </p>
50
  </div>
51
  <div class="buy-full">
82
  <li>Responsive calendar themes</li>
83
  <li>Professional support</li>
84
  </ul>
85
+ <span><small>starting at</small><h2>&dollar;39 </h2></span>
86
  <div class="bottom">
87
+ <a href="http://www.wpsimplebookingcalendar.com/" target="_blank" class="button">Read more</a>
88
  </div>
89
  <small class="bottom">100% money-back guarantee!</small>
90
  </div>
views/shortcode/metabox.phtml CHANGED
@@ -5,37 +5,9 @@
5
  * Copyright (c) 2010 Lennart Visscher
6
  */
7
 
8
- function renderTokenOption(WpSimpleBookingCalendar_View $view, $title, $name, $options)
9
- {
10
- ?>
11
- <tr>
12
- <th scope="row">
13
- <label for="sbcMetabox_<?php esc_attr_e($name) ?>"><?php echo $title ?>:</label>
14
- </th>
15
- <td>
16
- <select name="sbcMetabox[<?php esc_attr_e($name) ?>]" id="sbcMetabox_<?php esc_attr_e($name) ?>">
17
- <?php foreach ((array) $options as $value => $label): ?>
18
- <option value="<?php esc_attr_e($value) ?>"><?php esc_html_e($label) ?></option>
19
- <?php endforeach ?>
20
- </select>
21
- </td>
22
- </tr>
23
- <?php
24
- }
25
-
26
  ?>
27
- <table class="form-table">
28
- <tbody>
29
- <?php
30
- $yesNoOptions = array('yes' => __('Yes', 'sbc'), 'no' => __('No', 'sbc'));
31
-
32
- renderTokenOption($this, __('Show Calendar Title', 'sbc'), 'title', $yesNoOptions);
33
- ?>
34
- </tbody>
35
- </table>
36
 
37
- <p class="submit">
38
- <input type="button" value="<?php esc_attr_e('Send Token to Editor &raquo;', 'sbc') ?>" />
39
- </p>
40
 
41
  <div class="clear"></div>
5
  * Copyright (c) 2010 Lennart Visscher
6
  */
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ?>
 
 
 
 
 
 
 
 
 
9
 
10
+
11
+ <p><?php echo __( 'To add the calendar, copy and paste one of the following shortcodes: [sbc title="yes"] or [sbc title="no"]', 'sbc' ); ?></p>
 
12
 
13
  <div class="clear"></div>
wp-simple-booking-calendar.php CHANGED
@@ -3,35 +3,35 @@
3
  * Plugin Name: WP Simple Booking Calendar
4
  * Plugin URI: http://www.wpsimplebookingcalendar.com
5
  * Description: WP Simple Booking Calendar - Free Version.
6
- * Version: 1.5.1
7
  * Author: WP Simple Booking Calendar
8
  * Author URI: http://www.wpsimplebookingcalendar.com
9
  * License: GPL2
10
  *
11
- * Copyright (c) 2015 WP Simple Booking Calendar
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  */
13
-
14
- /* Copyright 2015 WP Simple Booking Calendar
15
 
16
- This program is free software; you can redistribute it and/or modify
17
- it under the terms of the GNU General Public License, version 2, as
18
- published by the Free Software Foundation.
19
-
20
- This program is distributed in the hope that it will be useful,
21
- but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
- GNU General Public License for more details.
24
-
25
- You should have received a copy of the GNU General Public License
26
- along with this program; if not, write to the Free Software
27
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
- */
29
 
30
  // Translation
31
  load_plugin_textdomain('sbc', false, dirname(plugin_basename(__FILE__)) . '/languages/');
32
 
33
  // Initialization
34
- define('SBC_DIR_URL', plugin_dir_url(__FILE__));
 
35
 
36
  require_once 'library/WpSimpleBookingCalendar/Exception.php';
37
  require_once 'library/WpSimpleBookingCalendar/Model.php';
@@ -42,4 +42,7 @@ require_once 'library/WpSimpleBookingCalendar/Widget.php';
42
  require_once 'library/WpSimpleBookingCalendar/Ajax.php';
43
  require_once 'library/WpSimpleBookingCalendar.php';
44
 
 
 
 
45
  WpSimpleBookingCalendar::init();
3
  * Plugin Name: WP Simple Booking Calendar
4
  * Plugin URI: http://www.wpsimplebookingcalendar.com
5
  * Description: WP Simple Booking Calendar - Free Version.
6
+ * Version: 1.5.5
7
  * Author: WP Simple Booking Calendar
8
  * Author URI: http://www.wpsimplebookingcalendar.com
9
  * License: GPL2
10
  *
11
+ * Copyright (c) 2018 WP Simple Booking Calendar
12
+ *
13
+ * This program is free software; you can redistribute it and/or modify
14
+ * it under the terms of the GNU General Public License, version 2, as
15
+ * published by the Free Software Foundation.
16
+ *
17
+ * This program is distributed in the hope that it will be useful,
18
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
+ * GNU General Public License for more details.
21
+ *
22
+ * You should have received a copy of the GNU General Public License
23
+ * along with this program; if not, write to the Free Software
24
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
+ *
26
  */
 
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  // Translation
30
  load_plugin_textdomain('sbc', false, dirname(plugin_basename(__FILE__)) . '/languages/');
31
 
32
  // Initialization
33
+ define( 'SBC_VERSION', '1.5.5' );
34
+ define( 'SBC_DIR_URL', plugin_dir_url( __FILE__ ) );
35
 
36
  require_once 'library/WpSimpleBookingCalendar/Exception.php';
37
  require_once 'library/WpSimpleBookingCalendar/Model.php';
42
  require_once 'library/WpSimpleBookingCalendar/Ajax.php';
43
  require_once 'library/WpSimpleBookingCalendar.php';
44
 
45
+ // Block
46
+ require_once 'blocks/sbc/functions.php';
47
+
48
  WpSimpleBookingCalendar::init();