The Events Calendar Shortcode - Version 2.5.3

Version Description

  • Fix for month="next" when near the end of a month
Download this release

Release Info

Developer brianhogg
Plugin Icon 128x128 The Events Calendar Shortcode
Version 2.5.3
Comparing to
See all releases

Code changes from version 2.5.2 to 2.5.3

block/init.php CHANGED
@@ -5,11 +5,11 @@
5
  * @since 1.9.0
6
  */
7
  function ecs_register_block() {
8
- if ( ! function_exists( 'register_block_type' ) ) {
9
- return;
10
- }
11
 
12
- // Avoid loading if the cornerstone page builder plugin is installed due to conflicts
13
  if ( class_exists( 'Cornerstone_Plugin' ) ) {
14
  return;
15
  }
@@ -20,73 +20,72 @@ function ecs_register_block() {
20
  }
21
 
22
  wp_register_script(
23
- 'ecs-block-js',
24
- plugins_url( 'static/block.js', dirname( __FILE__ ) ),
25
- array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ),
26
- Events_Calendar_Shortcode::VERSION
27
- );
28
 
29
- if ( function_exists( 'wp_set_script_translations' ) ) {
30
  wp_set_script_translations( 'ecs-block', 'the-events-calendar-shortcode' );
31
  }
32
 
33
- wp_register_style(
34
- 'ecs-block-css',
35
- plugins_url( 'static/ecs-block.css', dirname( __FILE__ ) ),
36
- array(),
37
  Events_Calendar_Shortcode::VERSION
38
  );
39
 
40
- $attributes = apply_filters( 'ecs_block_attributes', array(
41
- 'design' => array(
42
- 'type' => 'string',
43
- 'default' => 'standard',
44
- ),
45
- 'limit' => array(
46
- 'type' => 'number',
47
- ),
48
- 'settings' => array(
49
- 'type' => 'string',
50
- 'default' => json_encode( array( 'design', 'limit' ) ),
51
- ),
52
- 'cat' => array( 'type' => 'string' ),
53
- 'month' => array( 'type' => 'string' ),
54
- 'thumb' => array(
55
  'type' => 'string',
 
56
  ),
57
- 'thumbsize' => array( 'type' => 'string' ),
58
- 'thumbwidth' => array(
59
- 'type' => 'string',
60
  ),
61
- 'thumbheight' => array(
62
- 'type' => 'string',
 
63
  ),
64
- 'venue' => array(
65
- 'type' => 'string',
 
 
66
  ),
67
- 'past' => array( 'type' => 'string' ),
68
- 'orderby' => array(
69
- 'type' => 'string',
70
  ),
71
- 'order' => array(
72
- 'type' => 'string',
73
  ),
74
- 'excerpt' => array(
75
- 'type' => 'string',
76
  ),
77
- 'keyValue' => array( 'type' => 'string' ),
78
- ) );
 
 
 
 
 
 
 
 
 
 
79
 
80
- register_block_type( 'events-calendar-shortcode/block', array(
81
- 'editor_style' => 'ecs-block-css',
82
  'editor_script' => 'ecs-block-js',
83
- 'render_callback' => 'ecs_render_block',
84
- 'attributes' => $attributes,
85
- ) );
86
  }
87
  add_action( 'init', 'ecs_register_block' );
88
 
89
-
90
  /**
91
  * Maps the saved block attributes to the existing shortcode for front-end render
92
  *
@@ -95,27 +94,28 @@ add_action( 'init', 'ecs_register_block' );
95
  * @since 1.9.0
96
  */
97
  function ecs_render_block( $attributes ) {
98
- $attribute_str = '';
99
 
100
- foreach ( $attributes as $key => $value ) {
101
- if ( $key === 'settings' )
102
- continue;
 
103
 
104
- if ( $key === 'keyValue' ) {
105
- $kv_attributes = json_decode( $value );
106
 
107
- foreach ( $kv_attributes as $kv_attribute ) {
108
- $attribute_str .= " {$kv_attribute->key}=\"{$kv_attribute->value}\"";
109
- }
110
- continue;
111
- }
112
 
113
- if ( isset( $attributes[ $key ] ) && ! empty( $attributes[ $key ] ) ) {
114
- $attribute_str .= " {$key}=\"{$value}\"";
115
- }
116
- }
117
 
118
- $shortcode_str = "[ecs-list-events{$attribute_str}]";
119
 
120
- return do_shortcode( $shortcode_str );
121
  }
5
  * @since 1.9.0
6
  */
7
  function ecs_register_block() {
8
+ if ( ! function_exists( 'register_block_type' ) ) {
9
+ return;
10
+ }
11
 
12
+ // Avoid loading if the cornerstone page builder plugin is installed due to conflicts
13
  if ( class_exists( 'Cornerstone_Plugin' ) ) {
14
  return;
15
  }
20
  }
21
 
22
  wp_register_script(
23
+ 'ecs-block-js',
24
+ plugins_url( 'static/block.js', __DIR__ ),
25
+ array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' ),
26
+ Events_Calendar_Shortcode::VERSION
27
+ );
28
 
29
+ if ( function_exists( 'wp_set_script_translations' ) ) {
30
  wp_set_script_translations( 'ecs-block', 'the-events-calendar-shortcode' );
31
  }
32
 
33
+ wp_register_style(
34
+ 'ecs-block-css',
35
+ plugins_url( 'static/ecs-block.css', __DIR__ ),
36
+ array(),
37
  Events_Calendar_Shortcode::VERSION
38
  );
39
 
40
+ $attributes = apply_filters( 'ecs_block_attributes', array(
41
+ 'design' => array(
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  'type' => 'string',
43
+ 'default' => 'standard',
44
  ),
45
+ 'limit' => array(
46
+ 'type' => 'number',
 
47
  ),
48
+ 'settings' => array(
49
+ 'type' => 'string',
50
+ 'default' => json_encode( array( 'design', 'limit' ) ),
51
  ),
52
+ 'cat' => array( 'type' => 'string' ),
53
+ 'month' => array( 'type' => 'string' ),
54
+ 'thumb' => array(
55
+ 'type' => 'string',
56
  ),
57
+ 'thumbsize' => array( 'type' => 'string' ),
58
+ 'thumbwidth' => array(
59
+ 'type' => 'string',
60
  ),
61
+ 'thumbheight' => array(
62
+ 'type' => 'string',
63
  ),
64
+ 'venue' => array(
65
+ 'type' => 'string',
66
  ),
67
+ 'past' => array( 'type' => 'string' ),
68
+ 'orderby' => array(
69
+ 'type' => 'string',
70
+ ),
71
+ 'order' => array(
72
+ 'type' => 'string',
73
+ ),
74
+ 'excerpt' => array(
75
+ 'type' => 'string',
76
+ ),
77
+ 'keyValue' => array( 'type' => 'string' ),
78
+ ) );
79
 
80
+ register_block_type( 'events-calendar-shortcode/block', array(
81
+ 'editor_style' => 'ecs-block-css',
82
  'editor_script' => 'ecs-block-js',
83
+ 'render_callback' => 'ecs_render_block',
84
+ 'attributes' => $attributes,
85
+ ) );
86
  }
87
  add_action( 'init', 'ecs_register_block' );
88
 
 
89
  /**
90
  * Maps the saved block attributes to the existing shortcode for front-end render
91
  *
94
  * @since 1.9.0
95
  */
96
  function ecs_render_block( $attributes ) {
97
+ $attribute_str = '';
98
 
99
+ foreach ( $attributes as $key => $value ) {
100
+ if ( $key === 'settings' ) {
101
+ continue;
102
+ }
103
 
104
+ if ( $key === 'keyValue' ) {
105
+ $kv_attributes = json_decode( $value );
106
 
107
+ foreach ( $kv_attributes as $kv_attribute ) {
108
+ $attribute_str .= " {$kv_attribute->key}=\"{$kv_attribute->value}\"";
109
+ }
110
+ continue;
111
+ }
112
 
113
+ if ( isset( $attributes[ $key ] ) && ! empty( $attributes[ $key ] ) ) {
114
+ $attribute_str .= " {$key}=\"{$value}\"";
115
+ }
116
+ }
117
 
118
+ $shortcode_str = "[ecs-list-events{$attribute_str}]";
119
 
120
+ return do_shortcode( $shortcode_str );
121
  }
includes/ajax-endpoints.php CHANGED
@@ -3,15 +3,15 @@
3
  * Save the option to show a link underneath events or not
4
  */
5
  function ajax_ecs_save_show_link_value() {
6
- if ( ! is_user_logged_in() || ! wp_verify_nonce( $_POST['nonce'], 'ecs-link-nonce' ) ) {
7
- die(-1);
8
- }
9
 
10
- update_option( 'ecs-show-link', ( isset( $_POST['value'] ) && 'true' == $_POST['value'] ) ? true : false );
11
- wp_send_json( array(
12
- 'success' => 'true',
13
- 'value' => get_option( 'ecs-show-link' ) ? true : false
14
- ) );
15
  }
16
 
17
- add_action( 'wp_ajax_ecs_show_link', 'ajax_ecs_save_show_link_value' );
3
  * Save the option to show a link underneath events or not
4
  */
5
  function ajax_ecs_save_show_link_value() {
6
+ if ( ! is_user_logged_in() || ! wp_verify_nonce( $_POST['nonce'], 'ecs-link-nonce' ) ) {
7
+ die( -1 );
8
+ }
9
 
10
+ update_option( 'ecs-show-link', ( isset( $_POST['value'] ) && 'true' == $_POST['value'] ) ? true : false );
11
+ wp_send_json( array(
12
+ 'success' => 'true',
13
+ 'value' => get_option( 'ecs-show-link' ) ? true : false,
14
+ ) );
15
  }
16
 
17
+ add_action( 'wp_ajax_ecs_show_link', 'ajax_ecs_save_show_link_value' );
includes/notices/discounts.php CHANGED
@@ -3,25 +3,24 @@
3
  define( 'ECS_DISCOUNT_OPTION_NAME', 'ecs_hide_discounts_notice_q4_2018' );
4
 
5
  function ecs_setup_discounts_notice() {
6
- if ( defined( 'TECS_VERSION' ) ||
7
- get_option( 'ecs_hide_discounts_notice_q4_2018', false ) ||
8
- time() > strtotime( '2018-11-30 23:59:59' ) ) {
9
- return;
10
- }
11
- add_action( 'admin_notices', 'ecs_display_discounts_notice' );
12
  }
13
  add_action( 'admin_init', 'ecs_setup_discounts_notice' );
14
 
15
  function ecs_display_discounts_notice() {
16
- $screen = get_current_screen();
17
- if ( ! is_object( $screen ) ||
18
- (
19
- 'dashboard' !== $screen->id &&
20
- 'tribe_events' !== $screen->post_type
21
- ) ) {
22
- return;
23
- }
24
- ?>
25
  <div class="notice notice-success ecs_notice_server ecs-dismissible-notice is-dismissible">
26
  <h3><?php esc_html_e( 'Save on The Events Calendar Shortcode PRO for a limited time.', 'the-events-calendar-shortcode' ); ?></h3>
27
  <p><?php esc_html_e( 'Our annual sale is a good opportunity to get beautiful designs and more options for your event listings. Don’t miss out!', 'the-events-calendar-shortcode' ); ?></p>
@@ -35,6 +34,6 @@ function ecs_display_discounts_notice() {
35
  }
36
 
37
  function ecs_dismiss_discounts_notice() {
38
- update_option( 'ecs_hide_discounts_notice_q4_2018', true );
39
  }
40
- add_action( 'wp_ajax_ecs_dismiss_discounts_notice', 'ecs_dismiss_discounts_notice' );
3
  define( 'ECS_DISCOUNT_OPTION_NAME', 'ecs_hide_discounts_notice_q4_2018' );
4
 
5
  function ecs_setup_discounts_notice() {
6
+ if ( defined( 'TECS_VERSION' ) ||
7
+ get_option( 'ecs_hide_discounts_notice_q4_2018', false ) ||
8
+ time() > strtotime( '2018-11-30 23:59:59' ) ) {
9
+ return;
10
+ }
11
+ add_action( 'admin_notices', 'ecs_display_discounts_notice' );
12
  }
13
  add_action( 'admin_init', 'ecs_setup_discounts_notice' );
14
 
15
  function ecs_display_discounts_notice() {
16
+ $screen = get_current_screen();
17
+ if ( ! is_object( $screen ) ||
18
+ (
19
+ 'dashboard' !== $screen->id &&
20
+ 'tribe_events' !== $screen->post_type
21
+ ) ) {
22
+ return;
23
+ } ?>
 
24
  <div class="notice notice-success ecs_notice_server ecs-dismissible-notice is-dismissible">
25
  <h3><?php esc_html_e( 'Save on The Events Calendar Shortcode PRO for a limited time.', 'the-events-calendar-shortcode' ); ?></h3>
26
  <p><?php esc_html_e( 'Our annual sale is a good opportunity to get beautiful designs and more options for your event listings. Don’t miss out!', 'the-events-calendar-shortcode' ); ?></p>
34
  }
35
 
36
  function ecs_dismiss_discounts_notice() {
37
+ update_option( 'ecs_hide_discounts_notice_q4_2018', true );
38
  }
39
+ add_action( 'wp_ajax_ecs_dismiss_discounts_notice', 'ecs_dismiss_discounts_notice' );
includes/wp-requirements.php CHANGED
@@ -4,268 +4,248 @@
4
  *
5
  * Utility to check current PHP version, WordPress version and PHP extensions.
6
  *
7
- * @package WP_Requirements
8
  * @version 1.4.0
 
9
  * @author Fulvio Notarstefano <fulvio.notarstefano@gmail.com>
10
- * @link https://github.com/nekojira/wp-requirements
 
 
11
  * @license GPL2+
12
  */
13
-
14
  if ( ! class_exists( 'TECS_WP_Requirements' ) ) {
15
-
16
- class TECS_WP_Requirements {
17
-
18
- /**
19
- * Plugin name.
20
- *
21
- * @access private
22
- * @var string
23
- */
24
- private $name = '';
25
-
26
- /**
27
- * Plugin main file.
28
- *
29
- * plugin_basename( __FILE__ )
30
- *
31
- * @access private
32
- * @var string
33
- */
34
- private $plugin = '';
35
-
36
- /**
37
- * WordPress.
38
- *
39
- * @access private
40
- * @var bool
41
- */
42
- private $wp = true;
43
-
44
- /**
45
- * PHP.
46
- *
47
- * @access private
48
- * @var bool
49
- */
50
- private $php = true;
51
-
52
- /**
53
- * PHP Extensions.
54
- *
55
- * @access private
56
- * @var bool
57
- */
58
- private $extensions = true;
59
-
60
- /**
61
- * Requirements to check.
62
- *
63
- * @access private
64
- * @var array
65
- */
66
- private $requirements = array();
67
-
68
- /**
69
- * Results failures.
70
- *
71
- * Associative array with requirements results.
72
- *
73
- * @access private
74
- * @var array
75
- */
76
- private $failures = array();
77
-
78
- /**
79
- * Admin notice.
80
- *
81
- * @access private
82
- * @var string
83
- */
84
- private $notice = '';
85
-
86
- /**
87
- * Run checks.
88
- *
89
- * @param string $name The plugin name.
90
- * @param string $plugin Output of `plugin_basename( __FILE__ )`.
91
- * @param array $requirements Associative array with requirements.
92
- */
93
- public function __construct( $name, $plugin, $requirements ) {
94
-
95
- $this->name = htmlspecialchars( strip_tags( $name ) );
96
- $this->plugin = $plugin;
97
- $this->requirements = $requirements;
98
-
99
- if ( ! empty( $requirements ) && is_array( $requirements ) ) {
100
-
101
- $failures = $extensions = array();
102
-
103
- $requirements = array_merge(
104
- array(
105
- 'WordPress' => '',
106
- 'PHP' => '',
107
- 'Extensions' => '',
108
- ), $requirements
109
- );
110
-
111
- // Check for WordPress version.
112
- if ( $requirements['WordPress'] && is_string( $requirements['WordPress'] ) ) {
113
- if ( function_exists( 'get_bloginfo' ) ) {
114
- $wp_version = get_bloginfo( 'version' );
115
- if ( version_compare( $wp_version, $requirements['WordPress'] ) === - 1 ) {
116
- $failures['WordPress'] = $wp_version;
117
- $this->wp = false;
118
- }
119
- }
120
- }
121
-
122
- // Check fo PHP version.
123
- if ( $requirements['PHP'] && is_string( $requirements['PHP'] ) ) {
124
- if ( version_compare( PHP_VERSION, $requirements['PHP'] ) === -1 ) {
125
- $failures['PHP'] = PHP_VERSION;
126
- $this->php = false;
127
- }
128
- }
129
-
130
- // Check fo PHP Extensions.
131
- if ( $requirements['Extensions'] && is_array( $requirements['Extensions'] ) ) {
132
- foreach ( $requirements['Extensions'] as $extension ) {
133
- if ( $extension && is_string( $extension ) ) {
134
- $extensions[ $extension ] = extension_loaded( $extension );
135
- }
136
- }
137
- if ( in_array( false, $extensions ) ) {
138
- foreach ( $extensions as $extension_name => $found ) {
139
- if ( $found === false ) {
140
- $failures['Extensions'][ $extension_name ] = $extension_name;
141
- }
142
- }
143
- $this->extensions = false;
144
- }
145
- }
146
-
147
- $this->failures = $failures;
148
-
149
- } else {
150
-
151
- trigger_error( 'WP Requirements: the requirements are invalid.', E_USER_ERROR );
152
-
153
- }
154
- }
155
-
156
- /**
157
- * Get requirements results.
158
- *
159
- * @return array
160
- */
161
- public function failures() {
162
- return $this->failures;
163
- }
164
-
165
- /**
166
- * Check if versions check pass.
167
- *
168
- * @return bool
169
- */
170
- public function pass() {
171
- if ( in_array( false, array(
172
- $this->wp,
173
- $this->php,
174
- $this->extensions,
175
- ) ) ) {
176
- return false;
177
- }
178
- return true;
179
- }
180
-
181
- /**
182
- * Notice message.
183
- *
184
- * @param string $message An additional message.
185
- *
186
- * @return string
187
- */
188
- public function get_notice( $message = '' ) {
189
-
190
- $notice = '';
191
- $name = $this->name;
192
- $failures = $this->failures;
193
-
194
- if ( ! empty( $failures ) && is_array( $failures ) ) {
195
-
196
- $notice = '<div class="error">' . "\n";
197
- $notice .= "\t" . '<p>' . "\n";
198
- $notice .= '<strong>' . sprintf( '%s could not be activated.', $name ) . '</strong><br>';
199
-
200
- foreach ( $failures as $requirement => $found ) {
201
-
202
- $required = $this->requirements[ $requirement ];
203
-
204
- if ( 'Extensions' == $requirement ) {
205
- if ( is_array( $found ) ) {
206
- $notice .= sprintf(
207
- 'Required PHP Extension(s) not found: %s.',
208
- join( ', ', $found )
209
- ) . '<br>';
210
- }
211
- } else {
212
- $notice .= sprintf(
213
- 'Required %1$s version: %2$s - Version found: %3$s',
214
- $requirement,
215
- $required,
216
- $found
217
- ) . '<br>';
218
- }
219
-
220
- }
221
-
222
- $notice .= '<em>' . sprintf( 'Please update to meet %s requirements.', $name ) . '</em>' . "\n";
223
- $notice .= "\t" . '</p>' . "\n";
224
- if ( $message ) {
225
- $notice .= $message;
226
- }
227
- $notice .= '</div>';
228
- }
229
-
230
- return $notice;
231
- }
232
-
233
- /**
234
- * Print notice.
235
- */
236
- public function print_notice() {
237
- echo $this->notice;
238
- }
239
-
240
- /**
241
- * Deactivate plugin.
242
- */
243
- public function deactivate_plugin() {
244
- if ( function_exists( 'deactivate_plugins' ) && function_exists( 'plugin_basename' ) ) {
245
- deactivate_plugins( $this->plugin );
246
- }
247
- }
248
-
249
- /**
250
- * Deactivate plugin and display admin notice.
251
- *
252
- * @param string $message An additional message in notice.
253
- */
254
- public function halt( $message = '' ) {
255
-
256
- $this->notice = $this->get_notice( $message );
257
-
258
- if ( $this->notice && function_exists( 'add_action' ) ) {
259
-
260
- add_action( 'admin_notices', array( $this, 'print_notice' ) );
261
- add_action( 'admin_init', array( $this, 'deactivate_plugin' ) );
262
-
263
- if ( isset( $_GET['activate'] ) ) {
264
- unset( $_GET['activate'] );
265
- }
266
- }
267
- }
268
-
269
- }
270
-
271
  }
4
  *
5
  * Utility to check current PHP version, WordPress version and PHP extensions.
6
  *
 
7
  * @version 1.4.0
8
+ *
9
  * @author Fulvio Notarstefano <fulvio.notarstefano@gmail.com>
10
+ *
11
+ * @see https://github.com/nekojira/wp-requirements
12
+ *
13
  * @license GPL2+
14
  */
 
15
  if ( ! class_exists( 'TECS_WP_Requirements' ) ) {
16
+ class TECS_WP_Requirements {
17
+
18
+ /**
19
+ * Plugin name.
20
+ *
21
+ * @var string
22
+ */
23
+ private $name = '';
24
+
25
+ /**
26
+ * Plugin main file.
27
+ *
28
+ * plugin_basename( __FILE__ )
29
+ *
30
+ * @var string
31
+ */
32
+ private $plugin = '';
33
+
34
+ /**
35
+ * WordPress.
36
+ *
37
+ * @var bool
38
+ */
39
+ private $wp = true;
40
+
41
+ /**
42
+ * PHP.
43
+ *
44
+ * @var bool
45
+ */
46
+ private $php = true;
47
+
48
+ /**
49
+ * PHP Extensions.
50
+ *
51
+ * @var bool
52
+ */
53
+ private $extensions = true;
54
+
55
+ /**
56
+ * Requirements to check.
57
+ *
58
+ * @var array
59
+ */
60
+ private $requirements = array();
61
+
62
+ /**
63
+ * Results failures.
64
+ *
65
+ * Associative array with requirements results.
66
+ *
67
+ * @var array
68
+ */
69
+ private $failures = array();
70
+
71
+ /**
72
+ * Admin notice.
73
+ *
74
+ * @var string
75
+ */
76
+ private $notice = '';
77
+
78
+ /**
79
+ * Run checks.
80
+ *
81
+ * @param string $name the plugin name
82
+ * @param string $plugin output of `plugin_basename( __FILE__ )`
83
+ * @param array $requirements associative array with requirements
84
+ */
85
+ public function __construct( $name, $plugin, $requirements ) {
86
+ $this->name = htmlspecialchars( strip_tags( $name ) );
87
+ $this->plugin = $plugin;
88
+ $this->requirements = $requirements;
89
+
90
+ if ( ! empty( $requirements ) && is_array( $requirements ) ) {
91
+ $failures = $extensions = array();
92
+
93
+ $requirements = array_merge(
94
+ array(
95
+ 'WordPress' => '',
96
+ 'PHP' => '',
97
+ 'Extensions' => '',
98
+ ), $requirements
99
+ );
100
+
101
+ // Check for WordPress version.
102
+ if ( $requirements['WordPress'] && is_string( $requirements['WordPress'] ) ) {
103
+ if ( function_exists( 'get_bloginfo' ) ) {
104
+ $wp_version = get_bloginfo( 'version' );
105
+ if ( version_compare( $wp_version, $requirements['WordPress'] ) === - 1 ) {
106
+ $failures['WordPress'] = $wp_version;
107
+ $this->wp = false;
108
+ }
109
+ }
110
+ }
111
+
112
+ // Check fo PHP version.
113
+ if ( $requirements['PHP'] && is_string( $requirements['PHP'] ) ) {
114
+ if ( version_compare( PHP_VERSION, $requirements['PHP'] ) === -1 ) {
115
+ $failures['PHP'] = PHP_VERSION;
116
+ $this->php = false;
117
+ }
118
+ }
119
+
120
+ // Check fo PHP Extensions.
121
+ if ( $requirements['Extensions'] && is_array( $requirements['Extensions'] ) ) {
122
+ foreach ( $requirements['Extensions'] as $extension ) {
123
+ if ( $extension && is_string( $extension ) ) {
124
+ $extensions[ $extension ] = extension_loaded( $extension );
125
+ }
126
+ }
127
+ if ( in_array( false, $extensions ) ) {
128
+ foreach ( $extensions as $extension_name => $found ) {
129
+ if ( $found === false ) {
130
+ $failures['Extensions'][ $extension_name ] = $extension_name;
131
+ }
132
+ }
133
+ $this->extensions = false;
134
+ }
135
+ }
136
+
137
+ $this->failures = $failures;
138
+ } else {
139
+ trigger_error( 'WP Requirements: the requirements are invalid.', E_USER_ERROR );
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Get requirements results.
145
+ *
146
+ * @return array
147
+ */
148
+ public function failures() {
149
+ return $this->failures;
150
+ }
151
+
152
+ /**
153
+ * Check if versions check pass.
154
+ *
155
+ * @return bool
156
+ */
157
+ public function pass() {
158
+ if ( in_array( false, array(
159
+ $this->wp,
160
+ $this->php,
161
+ $this->extensions,
162
+ ) ) ) {
163
+ return false;
164
+ }
165
+
166
+ return true;
167
+ }
168
+
169
+ /**
170
+ * Notice message.
171
+ *
172
+ * @param string $message an additional message
173
+ *
174
+ * @return string
175
+ */
176
+ public function get_notice( $message = '' ) {
177
+ $notice = '';
178
+ $name = $this->name;
179
+ $failures = $this->failures;
180
+
181
+ if ( ! empty( $failures ) && is_array( $failures ) ) {
182
+ $notice = '<div class="error">' . "\n";
183
+ $notice .= "\t" . '<p>' . "\n";
184
+ $notice .= '<strong>' . sprintf( '%s could not be activated.', $name ) . '</strong><br>';
185
+
186
+ foreach ( $failures as $requirement => $found ) {
187
+ $required = $this->requirements[ $requirement ];
188
+
189
+ if ( 'Extensions' == $requirement ) {
190
+ if ( is_array( $found ) ) {
191
+ $notice .= sprintf(
192
+ 'Required PHP Extension(s) not found: %s.',
193
+ join( ', ', $found )
194
+ ) . '<br>';
195
+ }
196
+ } else {
197
+ $notice .= sprintf(
198
+ 'Required %1$s version: %2$s - Version found: %3$s',
199
+ $requirement,
200
+ $required,
201
+ $found
202
+ ) . '<br>';
203
+ }
204
+ }
205
+
206
+ $notice .= '<em>' . sprintf( 'Please update to meet %s requirements.', $name ) . '</em>' . "\n";
207
+ $notice .= "\t" . '</p>' . "\n";
208
+ if ( $message ) {
209
+ $notice .= $message;
210
+ }
211
+ $notice .= '</div>';
212
+ }
213
+
214
+ return $notice;
215
+ }
216
+
217
+ /**
218
+ * Print notice.
219
+ */
220
+ public function print_notice() {
221
+ echo $this->notice;
222
+ }
223
+
224
+ /**
225
+ * Deactivate plugin.
226
+ */
227
+ public function deactivate_plugin() {
228
+ if ( function_exists( 'deactivate_plugins' ) && function_exists( 'plugin_basename' ) ) {
229
+ deactivate_plugins( $this->plugin );
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Deactivate plugin and display admin notice.
235
+ *
236
+ * @param string $message an additional message in notice
237
+ */
238
+ public function halt( $message = '' ) {
239
+ $this->notice = $this->get_notice( $message );
240
+
241
+ if ( $this->notice && function_exists( 'add_action' ) ) {
242
+ add_action( 'admin_notices', array( $this, 'print_notice' ) );
243
+ add_action( 'admin_init', array( $this, 'deactivate_plugin' ) );
244
+
245
+ if ( isset( $_GET['activate'] ) ) {
246
+ unset( $_GET['activate'] );
247
+ }
248
+ }
249
+ }
250
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: brianhogg
3
  Tags: event, events, calendar, shortcode, modern tribe
4
  Requires at least: 4.1
5
  Requires PHP: 5.3
6
- Tested up to: 5.9
7
- Stable tag: 2.5.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -180,6 +180,9 @@ The [pro version of the plugin](https://eventcalendarnewsletter.com/the-events-c
180
 
181
  == Upgrade Notice ==
182
 
 
 
 
183
  = 2.5.2 =
184
  * Initial workaround for styling issues for the block in the new full-site editor
185
 
@@ -197,6 +200,9 @@ Adds link to full documentation
197
 
198
  == Changelog ==
199
 
 
 
 
200
  = 2.5.2 =
201
  * Initial workaround for styling issues for the block in the new full-site editor
202
 
3
  Tags: event, events, calendar, shortcode, modern tribe
4
  Requires at least: 4.1
5
  Requires PHP: 5.3
6
+ Tested up to: 6.0
7
+ Stable tag: 2.5.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
180
 
181
  == Upgrade Notice ==
182
 
183
+ = 2.5.3 =
184
+ * Fix for month="next" when near the end of a month
185
+
186
  = 2.5.2 =
187
  * Initial workaround for styling issues for the block in the new full-site editor
188
 
200
 
201
  == Changelog ==
202
 
203
+ = 2.5.3 =
204
+ * Fix for month="next" when near the end of a month
205
+
206
  = 2.5.2 =
207
  * Initial workaround for styling issues for the block in the new full-site editor
208
 
templates/admin-page.php CHANGED
@@ -5,8 +5,8 @@
5
 
6
  <p class="shortcode">[ecs-list-events cat='festival' limit='8']</p>
7
 
8
- <p><a href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode-short-walk-through-video/?utm_source=plugin&utm_medium=link&utm_campaign=full-documentation&utm_content=top" target="_blank"><?php echo esc_html( __( 'Watch a Short Walk Through Video', 'the-events-calendar-shortcode' ) ) ?></a></p>
9
- <p><a href="https://eventcalendarnewsletter.com/events-calendar-shortcode-pro-options/?utm_source=plugin&utm_medium=link&utm_campaign=full-documentation&utm_content=top" target="_blank"><?php echo esc_html( __( 'View Full Documentation', 'the-events-calendar-shortcode' ) ) ?></a></p>
10
  <table>
11
  <tbody>
12
  <tr valign="top">
@@ -78,10 +78,10 @@
78
 
79
  <?php if ( apply_filters( 'ecs_show_upgrades', true ) ): ?>
80
  <div id="ecs-link-display">
81
- <?php wp_nonce_field( 'ecs-link-nonce', 'ecs-link-nonce' ) ?>
82
  <h2>We hope this plugin is helping you out!</h2>
83
  <p>Would you like to show your thanks for the plugin? Add a small link underneath your events pointing to The Events Calendar Shortcode project.</p>
84
- <p><label><input type="checkbox" value="1" id="show-ecs-link"<?php echo ( get_option( 'ecs-show-link' ) ? ' checked' : '' ) ?>> Show small link to The Events Calendar Shortcode</label></p>
85
  <p class="small toggle-message" style="display:none;">Value saved</p>
86
  </div>
87
  <?php endif; ?>
@@ -95,11 +95,11 @@
95
 
96
  <?php if ( apply_filters( 'ecs_show_upgrades', true ) ): ?>
97
 
98
- <p><?php echo esc_html( __( 'By default the plugin does not include styling. Events are listed in ul li tags with appropriate classes for styling and you can add your own CSS:', 'the-events-calendar-shortcode' ) ) ?></p>
99
 
100
  <ul>
101
  <li>ul class="ecs-event-list"</li>
102
- <li>li class="ecs-event" &amp; "ecs-featured-event" <?php echo esc_html( __( '(if featured)', 'the-events-calendar-shortcode' ) ) ?></li>
103
  <li><?php echo esc_html( sprintf( __( 'event title link is %s', 'the-events-calendar-shortcode' ), 'H4 class="entry-title summary"' ) ); ?> </li>
104
  <li><?php echo esc_html( sprintf( __( 'date class is %s', 'the-events-calendar-shortcode' ), 'time' ) ); ?></li>
105
  <li><?php echo esc_html( sprintf( __( 'venue class is %s', 'the-events-calendar-shortcode' ), 'venue' ) ); ?></li>
@@ -109,44 +109,44 @@
109
 
110
  <div id="ecs-pro-description">
111
 
112
- <h3><?php echo esc_html__( 'Want a better looking design without adding any CSS?', 'the-events-calendar-shortcode' ) ?></h3>
113
  <p><?php echo sprintf( esc_html__( 'Check out %sThe Events Calendar Shortcode & Block PRO%s. Some examples of the designs:', 'the-events-calendar-shortcode' ), '<a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design&utm_content=description">', '</a>' ); ?></p>
114
  <div id="ecs-pro-designs">
115
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-1&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/shortcode-default-design-2.png', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version default design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
116
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-2&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/event-calendar-shortcode-compact-design.png', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version compact design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
117
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-calendar&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-calendar-demo.gif', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version calendar design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
118
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-columns&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-columns-photo-horizontal-design.png', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version horizontal/columns/photos design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
119
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-grouped&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-grouped-design.png', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version grouped design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
120
- <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-filter-bar&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-filter-bar-demo.gif', TECS_CORE_PLUGIN_FILE ) ?>"><br><?php echo esc_html( __( 'Pro version filter bar example', 'the-events-calendar-shortcode' ) ); ?></a></p>
121
  </div>
122
 
123
  <h3 class="additional-options"><?php echo esc_html__( "In addition to designs, you'll get more options including:", 'the-events-calendar-shortcode' ); ?></h3>
124
- <h4><?php echo esc_html__( 'Number of days', 'the-events-calendar-shortcode' ) ?></h4>
125
- <p><?php echo esc_html__( 'Choose how many days to show events from, ie. 1 day or a week', 'the-events-calendar-shortcode' ) ?></p>
126
- <h4><?php echo esc_html__( 'Tag', 'the-events-calendar-shortcode' ) ?></h4>
127
- <p><?php echo esc_html__( 'Filter events listed by one or more tags', 'the-events-calendar-shortcode' ) ?></p>
128
- <h4><?php echo esc_html__( 'Location', 'the-events-calendar-shortcode' ) ?></h4>
129
- <p><?php echo esc_html__( 'Display events by city, state/province, or country', 'the-events-calendar-shortcode' ) ?></p>
130
- <h4><?php echo esc_html__( 'Single Event', 'the-events-calendar-shortcode' ) ?></h4>
131
- <p><?php echo esc_html__( 'List the details of a single event by ID, for example on a blog post', 'the-events-calendar-shortcode' ) ?></p>
132
- <h4><?php echo esc_html__( 'Featured', 'the-events-calendar-shortcode' ) ?></h4>
133
- <p><?php echo esc_html__( 'Show only events marked as "featured"', 'the-events-calendar-shortcode' ) ?></p>
134
- <h4><?php echo esc_html__( 'Button', 'the-events-calendar-shortcode' ) ?></h4>
135
- <p><?php echo esc_html__( 'Add an easy to see button link to your event, and customize the colors/text', 'the-events-calendar-shortcode' ) ?></p>
136
- <h4><?php echo esc_html__( 'Date', 'the-events-calendar-shortcode' ) ?></h4>
137
- <p><?php echo esc_html__( 'Show only events for a specific day (ie. 2017-04-16), great for conferences', 'the-events-calendar-shortcode' ) ?></p>
138
- <h4><?php echo esc_html__( 'Year', 'the-events-calendar-shortcode' ) ?></h4>
139
- <p><?php echo esc_html__( 'Show only events for a specific year', 'the-events-calendar-shortcode' ) ?></p>
140
- <h4><?php echo esc_html__( 'Offset', 'the-events-calendar-shortcode' ) ?></h4>
141
- <p><?php echo esc_html__( 'Skip a certain number of events from the beginning, useful for using multiple shortcodes on the same page or splitting into columns.', 'the-events-calendar-shortcode' ) ?></p>
142
- <h4><?php echo esc_html__( 'Full Description', 'the-events-calendar-shortcode' ) ?></h4>
143
- <p><?php echo esc_html__( 'Use the full description instead of the excerpt (short description) of an event in the listing', 'the-events-calendar-shortcode' ) ?></p>
144
- <h4><?php echo esc_html__( 'Future Only', 'the-events-calendar-shortcode' ) ?></h4>
145
- <p><?php echo esc_html__( 'Only show events in the future even when using the month or year option.', 'the-events-calendar-shortcode' ) ?></p>
146
- <h4><?php echo esc_html__( 'Custom Design', 'the-events-calendar-shortcode' ) ?></h4>
147
- <p><?php echo esc_html__( 'Use the new default or compact designs, or create your own using one or more templates in your theme folder', 'the-events-calendar-shortcode' ) ?></p>
148
- <h4><?php echo esc_html__( 'Filter Bar', 'the-events-calendar-shortcode' ) ?></h4>
149
- <p><?php echo esc_html__( 'Allow visitors to change what events are displayed wherever you put a calendar view on your site', 'the-events-calendar-shortcode' ) ?></p>
150
  <p><?php echo sprintf( esc_html__( '%sGet The Events Calendar Shortcode & Block PRO%s', 'the-events-calendar-shortcode' ), '<a class="ecs-button" target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-after-options&utm_content=description">', '</a>' ); ?> or <a href="https://demo.eventcalendarnewsletter.com/the-events-calendar-shortcode/">see it in action</p>
151
  </div>
152
  <?php endif; ?>
5
 
6
  <p class="shortcode">[ecs-list-events cat='festival' limit='8']</p>
7
 
8
+ <p><a href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode-short-walk-through-video/?utm_source=plugin&utm_medium=link&utm_campaign=full-documentation&utm_content=top" target="_blank"><?php echo esc_html( __( 'Watch a Short Walk Through Video', 'the-events-calendar-shortcode' ) ); ?></a></p>
9
+ <p><a href="https://eventcalendarnewsletter.com/events-calendar-shortcode-pro-options/?utm_source=plugin&utm_medium=link&utm_campaign=full-documentation&utm_content=top" target="_blank"><?php echo esc_html( __( 'View Full Documentation', 'the-events-calendar-shortcode' ) ); ?></a></p>
10
  <table>
11
  <tbody>
12
  <tr valign="top">
78
 
79
  <?php if ( apply_filters( 'ecs_show_upgrades', true ) ): ?>
80
  <div id="ecs-link-display">
81
+ <?php wp_nonce_field( 'ecs-link-nonce', 'ecs-link-nonce' ); ?>
82
  <h2>We hope this plugin is helping you out!</h2>
83
  <p>Would you like to show your thanks for the plugin? Add a small link underneath your events pointing to The Events Calendar Shortcode project.</p>
84
+ <p><label><input type="checkbox" value="1" id="show-ecs-link"<?php echo get_option( 'ecs-show-link' ) ? ' checked' : ''; ?>> Show small link to The Events Calendar Shortcode</label></p>
85
  <p class="small toggle-message" style="display:none;">Value saved</p>
86
  </div>
87
  <?php endif; ?>
95
 
96
  <?php if ( apply_filters( 'ecs_show_upgrades', true ) ): ?>
97
 
98
+ <p><?php echo esc_html( __( 'By default the plugin does not include styling. Events are listed in ul li tags with appropriate classes for styling and you can add your own CSS:', 'the-events-calendar-shortcode' ) ); ?></p>
99
 
100
  <ul>
101
  <li>ul class="ecs-event-list"</li>
102
+ <li>li class="ecs-event" &amp; "ecs-featured-event" <?php echo esc_html( __( '(if featured)', 'the-events-calendar-shortcode' ) ); ?></li>
103
  <li><?php echo esc_html( sprintf( __( 'event title link is %s', 'the-events-calendar-shortcode' ), 'H4 class="entry-title summary"' ) ); ?> </li>
104
  <li><?php echo esc_html( sprintf( __( 'date class is %s', 'the-events-calendar-shortcode' ), 'time' ) ); ?></li>
105
  <li><?php echo esc_html( sprintf( __( 'venue class is %s', 'the-events-calendar-shortcode' ), 'venue' ) ); ?></li>
109
 
110
  <div id="ecs-pro-description">
111
 
112
+ <h3><?php echo esc_html__( 'Want a better looking design without adding any CSS?', 'the-events-calendar-shortcode' ); ?></h3>
113
  <p><?php echo sprintf( esc_html__( 'Check out %sThe Events Calendar Shortcode & Block PRO%s. Some examples of the designs:', 'the-events-calendar-shortcode' ), '<a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design&utm_content=description">', '</a>' ); ?></p>
114
  <div id="ecs-pro-designs">
115
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-1&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/shortcode-default-design-2.png', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version default design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
116
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-2&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/event-calendar-shortcode-compact-design.png', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version compact design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
117
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-calendar&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-calendar-demo.gif', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version calendar design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
118
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-columns&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-columns-photo-horizontal-design.png', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version horizontal/columns/photos design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
119
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-grouped&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-grouped-design.png', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version grouped design example', 'the-events-calendar-shortcode' ) ); ?></a></p>
120
+ <p><a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-design-image-filter-bar&utm_content=description"><img alt="" style="width: 300px;" src="<?php echo plugins_url( '/static/the-events-calendar-shortcode-filter-bar-demo.gif', TECS_CORE_PLUGIN_FILE ); ?>"><br><?php echo esc_html( __( 'Pro version filter bar example', 'the-events-calendar-shortcode' ) ); ?></a></p>
121
  </div>
122
 
123
  <h3 class="additional-options"><?php echo esc_html__( "In addition to designs, you'll get more options including:", 'the-events-calendar-shortcode' ); ?></h3>
124
+ <h4><?php echo esc_html__( 'Number of days', 'the-events-calendar-shortcode' ); ?></h4>
125
+ <p><?php echo esc_html__( 'Choose how many days to show events from, ie. 1 day or a week', 'the-events-calendar-shortcode' ); ?></p>
126
+ <h4><?php echo esc_html__( 'Tag', 'the-events-calendar-shortcode' ); ?></h4>
127
+ <p><?php echo esc_html__( 'Filter events listed by one or more tags', 'the-events-calendar-shortcode' ); ?></p>
128
+ <h4><?php echo esc_html__( 'Location', 'the-events-calendar-shortcode' ); ?></h4>
129
+ <p><?php echo esc_html__( 'Display events by city, state/province, or country', 'the-events-calendar-shortcode' ); ?></p>
130
+ <h4><?php echo esc_html__( 'Single Event', 'the-events-calendar-shortcode' ); ?></h4>
131
+ <p><?php echo esc_html__( 'List the details of a single event by ID, for example on a blog post', 'the-events-calendar-shortcode' ); ?></p>
132
+ <h4><?php echo esc_html__( 'Featured', 'the-events-calendar-shortcode' ); ?></h4>
133
+ <p><?php echo esc_html__( 'Show only events marked as "featured"', 'the-events-calendar-shortcode' ); ?></p>
134
+ <h4><?php echo esc_html__( 'Button', 'the-events-calendar-shortcode' ); ?></h4>
135
+ <p><?php echo esc_html__( 'Add an easy to see button link to your event, and customize the colors/text', 'the-events-calendar-shortcode' ); ?></p>
136
+ <h4><?php echo esc_html__( 'Date', 'the-events-calendar-shortcode' ); ?></h4>
137
+ <p><?php echo esc_html__( 'Show only events for a specific day (ie. 2017-04-16), great for conferences', 'the-events-calendar-shortcode' ); ?></p>
138
+ <h4><?php echo esc_html__( 'Year', 'the-events-calendar-shortcode' ); ?></h4>
139
+ <p><?php echo esc_html__( 'Show only events for a specific year', 'the-events-calendar-shortcode' ); ?></p>
140
+ <h4><?php echo esc_html__( 'Offset', 'the-events-calendar-shortcode' ); ?></h4>
141
+ <p><?php echo esc_html__( 'Skip a certain number of events from the beginning, useful for using multiple shortcodes on the same page or splitting into columns.', 'the-events-calendar-shortcode' ); ?></p>
142
+ <h4><?php echo esc_html__( 'Full Description', 'the-events-calendar-shortcode' ); ?></h4>
143
+ <p><?php echo esc_html__( 'Use the full description instead of the excerpt (short description) of an event in the listing', 'the-events-calendar-shortcode' ); ?></p>
144
+ <h4><?php echo esc_html__( 'Future Only', 'the-events-calendar-shortcode' ); ?></h4>
145
+ <p><?php echo esc_html__( 'Only show events in the future even when using the month or year option.', 'the-events-calendar-shortcode' ); ?></p>
146
+ <h4><?php echo esc_html__( 'Custom Design', 'the-events-calendar-shortcode' ); ?></h4>
147
+ <p><?php echo esc_html__( 'Use the new default or compact designs, or create your own using one or more templates in your theme folder', 'the-events-calendar-shortcode' ); ?></p>
148
+ <h4><?php echo esc_html__( 'Filter Bar', 'the-events-calendar-shortcode' ); ?></h4>
149
+ <p><?php echo esc_html__( 'Allow visitors to change what events are displayed wherever you put a calendar view on your site', 'the-events-calendar-shortcode' ); ?></p>
150
  <p><?php echo sprintf( esc_html__( '%sGet The Events Calendar Shortcode & Block PRO%s', 'the-events-calendar-shortcode' ), '<a class="ecs-button" target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=plugin&utm_medium=link&utm_campaign=tecs-help-after-options&utm_content=description">', '</a>' ); ?> or <a href="https://demo.eventcalendarnewsletter.com/the-events-calendar-shortcode/">see it in action</p>
151
  </div>
152
  <?php endif; ?>
the-events-calendar-shortcode.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: The Events Calendar Shortcode & Block
4
  Plugin URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
5
  Description: An addon to add shortcode and new editor block functionality for The Events Calendar Plugin by Modern Tribe.
6
- Version: 2.5.2
7
  Author: Event Calendar Newsletter
8
  Author URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode
9
  Contributors: brianhogg
@@ -14,9 +14,9 @@
14
 
15
  // Avoid direct calls to this file
16
  if ( !defined( 'ABSPATH' ) ) {
17
- header( 'Status: 403 Forbidden' );
18
- header( 'HTTP/1.1 403 Forbidden' );
19
- exit();
20
  }
21
 
22
  define( 'TECS_CORE_PLUGIN_FILE', __FILE__ );
@@ -26,178 +26,181 @@ include_once dirname( TECS_CORE_PLUGIN_FILE ) . '/block/init.php';
26
 
27
  // Check plugin requirements before loading plugin.
28
  $this_plugin_checks = new TECS_WP_Requirements( 'The Events Calendar Shortcode', plugin_basename( TECS_CORE_PLUGIN_FILE ), array(
29
- 'PHP' => '5.3.3',
30
- 'WordPress' => '4.1',
31
  'Extensions' => array(
32
  ),
33
  ) );
34
  if ( $this_plugin_checks->pass() === false ) {
35
  $this_plugin_checks->halt();
 
36
  return;
37
  }
38
 
39
  include_once dirname( TECS_CORE_PLUGIN_FILE ) . '/includes/ajax-endpoints.php';
40
  include_once dirname( TECS_CORE_PLUGIN_FILE ) . '/includes/notices/discounts.php';
41
 
42
- /**
43
  * Events calendar shortcode addon main class
44
  *
45
  * @package events-calendar-shortcode
46
  * @author Brian Hogg
47
- * @version 1.0.10
48
  */
49
 
50
  if ( ! class_exists( 'Events_Calendar_Shortcode' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
- class Events_Calendar_Shortcode
53
- {
54
- /**
55
- * Current version of the plugin.
56
- *
57
- * @since 1.0.0
58
- */
59
- const VERSION = '2.5.2';
60
-
61
- private $admin_page = null;
62
-
63
- const MENU_SLUG = 'ecs-admin';
64
-
65
- /**
66
- * Constructor. Hooks all interactions to initialize the class.
67
- *
68
- * @since 1.0.0
69
- * @access public
70
- *
71
- * @see add_shortcode()
72
- */
73
- public function __construct() {
74
- add_action( 'plugins_loaded', array( $this, 'verify_tec_installed' ), 2 );
75
- add_action( 'admin_menu', array( $this, 'add_menu_page' ), 1000 );
76
- add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_action_links' ) );
77
- add_shortcode( 'ecs-list-events', array( $this, 'ecs_fetch_events' ) );
78
- add_filter( 'ecs_ending_output', array( $this, 'add_event_schema_json' ), 10, 3 );
79
- add_filter( 'ecs_ending_output', array( $this, 'add_ecs_link' ), 10, 3 );
80
- add_action( 'plugins_loaded', array( $this, 'load_languages' ) );
81
- } // END __construct()
82
-
83
- public function load_languages() {
84
- if ( function_exists( 'tecsp_load_textdomain' ) )
85
- return;
86
- load_plugin_textdomain( 'the-events-calendar-shortcode', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
87
- }
88
-
89
- public function verify_tec_installed() {
90
- if ( ! class_exists( 'Tribe__Events__Main' ) or ! defined( 'Tribe__Events__Main::VERSION' )) {
91
- add_action( 'admin_notices', array( $this, 'show_tec_not_installed_message' ) );
92
- }
93
- }
94
-
95
- public function show_tec_not_installed_message() {
96
- if ( current_user_can( 'activate_plugins' ) ) {
97
- $url = 'plugin-install.php?s=the+events+calendar&tab=search&type=term';
98
- $title = __( 'The Events Calendar', 'tribe-events-ical-importer' );
99
- echo '<div class="error"><p>' . sprintf( esc_html( __( 'To begin using %s, please install the latest version of %s%s%s and add an event.', 'the-events-calendar-shortcode' ) ), 'The Events Calendar Shortcode', '<a href="' . esc_url( admin_url( $url ) ) . '" title="' . esc_attr( $title ) . '">', 'The Events Calendar', '</a>' ) . '</p></div>';
100
- }
101
- }
102
-
103
- public function add_menu_page() {
104
- if ( ! class_exists( 'Tribe__Settings' ) or ! method_exists( Tribe__Settings::instance(), 'should_setup_pages' ) or ! Tribe__Settings::instance()->should_setup_pages() ) {
105
- return;
106
- }
107
-
108
- $page_title = $menu_title = esc_html__( 'Shortcode & Block', 'the-events-calendar-shortcode' );
109
- $capability = apply_filters( 'ecs_admin_page_capability', 'install_plugins' );
110
-
111
- $where = Tribe__Settings::instance()->get_parent_slug();
112
-
113
- $this->admin_page = add_submenu_page( $where, $page_title, $menu_title, $capability, self::MENU_SLUG, array( $this, 'do_menu_page' ) );
114
-
115
- add_action( 'admin_print_styles-' . $this->admin_page, array( $this, 'enqueue' ) );
116
- add_action( 'admin_print_styles', array( $this, 'enqueue_submenu_style' ) );
117
- }
118
-
119
- public function enqueue() {
120
- wp_enqueue_style( 'ecs-admin-css', plugins_url( 'static/ecs-admin.css', __FILE__ ), array(), self::VERSION );
121
- wp_enqueue_script( 'ecs-admin-js', plugins_url( 'static/ecs-admin.min.js', __FILE__ ), array(), self::VERSION );
122
- }
123
-
124
- /**
125
- * Function to add a small CSS file to add some colour to the Shortcode submenu item
126
- */
127
- public function enqueue_submenu_style() {
128
- wp_enqueue_style( 'ecs-submenu-css', plugins_url( 'static/ecs-submenu.css', __FILE__ ), array(), self::VERSION );
129
- }
130
-
131
- public function do_menu_page() {
132
- include dirname( __FILE__ ) . '/templates/admin-page.php';
133
- }
134
-
135
- public function add_action_links( $links ) {
136
- $mylinks = array();
137
- if ( class_exists( 'Tribe__Settings' ) and method_exists( Tribe__Settings::instance(), 'should_setup_pages' ) and Tribe__Settings::instance()->should_setup_pages() )
138
- $mylinks[] = '<a href="' . admin_url( 'edit.php?post_type=tribe_events&page=ecs-admin' ) . '">' . esc_html__( 'Settings', 'the-events-calendar-shortcode' ) . '</a>';
139
- $mylinks[] = '<a target="_blank" style="color:#3db634; font-weight: bold;" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode/?utm_source=plugin-list&utm_medium=upgrade-link&utm_campaign=plugin-list&utm_content=action-link">' . esc_html__( 'Upgrade', 'the-events-calendar-shortcode' ) . '</a>';
140
-
141
- return array_merge( $links, $mylinks );
142
- }
143
-
144
- /**
145
- * Fetch and return required events.
146
- * @param array $atts shortcode attributes
147
- * @return string shortcode output
148
- */
149
- public function ecs_fetch_events( $atts ) {
150
- /**
151
- * Check if events calendar plugin method exists
152
- */
153
- if ( !function_exists( 'tribe_get_events' ) ) {
154
- return '';
155
- }
156
-
157
- global $post, $ecs_last_event_count;
158
- $output = '';
159
-
160
- $atts = shortcode_atts( apply_filters( 'ecs_shortcode_atts', array(
161
- 'cat' => '',
162
- 'month' => '',
163
- 'limit' => 5,
164
- 'eventdetails' => 'true',
165
- 'time' => null,
166
- 'past' => null,
167
- 'venue' => 'false',
168
- 'author' => null,
169
- 'schema' => 'true',
170
- 'message' => 'There are no upcoming %s at this time.',
171
- 'key' => 'End Date',
172
- 'order' => 'ASC',
173
- 'orderby' => 'startdate',
174
- 'viewall' => 'false',
175
- 'excerpt' => 'false',
176
- 'thumb' => 'false',
177
- 'thumbsize' => '',
178
- 'thumbwidth' => '',
179
- 'thumbheight' => '',
180
- 'contentorder' => apply_filters( 'ecs_default_contentorder', 'title, thumbnail, excerpt, date, venue', $atts ),
181
- 'event_tax' => '',
182
- ), $atts ), $atts, 'ecs-list-events' );
183
-
184
- // Category
185
- if ( $atts['cat'] ) {
186
- if ( strpos( $atts['cat'], "," ) !== false ) {
187
- $atts['cats'] = explode( ",", $atts['cat'] );
188
- $atts['cats'] = array_map( 'trim', $atts['cats'] );
189
- } else {
190
- $atts['cats'] = array( trim( $atts['cat'] ) );
191
- }
192
-
193
- $atts['event_tax'] = array(
194
- 'relation' => 'OR',
195
- );
196
-
197
- foreach ( $atts['cats'] as $cat ) {
198
- $atts['event_tax'][] = array(
199
- 'relation' => 'OR',
200
- array(
201
  'taxonomy' => 'tribe_events_cat',
202
  'field' => 'name',
203
  'terms' => $cat,
@@ -206,83 +209,84 @@ class Events_Calendar_Shortcode
206
  'taxonomy' => 'tribe_events_cat',
207
  'field' => 'slug',
208
  'terms' => $cat,
209
- )
210
  );
211
- }
212
- }
213
-
214
- // Past Event
215
- $meta_date_compare = '>=';
216
- $meta_date_date = current_time( 'Y-m-d H:i:s' );
217
-
218
- if ( $atts['time'] == 'past' || !empty( $atts['past'] ) ) {
219
- $meta_date_compare = '<';
220
- }
221
-
222
- // Key, used in filtering events by date
223
- if ( str_replace( ' ', '', trim( strtolower( $atts['key'] ) ) ) == 'startdate' ) {
224
- $atts['key'] = '_EventStartDate';
225
- } else {
226
- $atts['key'] = '_EventEndDate';
227
- }
228
-
229
- // Orderby
230
- if ( str_replace( ' ', '', trim( strtolower( $atts['orderby'] ) ) ) == 'enddate' ) {
231
- $atts['orderby'] = '_EventEndDate';
232
- } elseif ( trim( strtolower( $atts['orderby'] ) ) == 'title' ) {
233
- $atts['orderby'] = 'title';
234
- } else {
235
- $atts['orderby'] = '_EventStartDate';
236
- }
237
-
238
- // Date
239
- $atts['meta_date'] = array(
240
- array(
241
- 'key' => $atts['key'],
242
- 'value' => $meta_date_date,
243
- 'compare' => $meta_date_compare,
244
- 'type' => 'DATETIME'
245
- )
246
- );
247
-
248
- // Specific Month
249
- if ( 'current' == $atts['month'] ) {
250
- $atts['month'] = current_time( 'Y-m' );
251
- }
252
- if ( 'next' == $atts['month'] ) {
253
- $atts['month'] = date( 'Y-m', strtotime( '+1 months', current_time( 'timestamp' ) ) );
254
- }
255
- if ($atts['month']) {
256
- $month_array = explode("-", $atts['month']);
257
-
258
- $month_yearstr = $month_array[0];
259
- $month_monthstr = $month_array[1];
260
- $month_startdate = date( "Y-m-d", strtotime( $month_yearstr . "-" . $month_monthstr . "-01" ) );
261
- $month_enddate = date( "Y-m-01", strtotime( "+1 month", strtotime( $month_startdate ) ) );
262
-
263
- $atts['meta_date'] = array(
264
- 'relation' => 'AND',
265
- array(
266
- 'key' => $atts['key'],
267
- 'value' => $month_startdate,
268
- 'compare' => '>=',
269
- 'type' => 'DATETIME'
270
- ),
271
- array(
272
- 'key' => $atts['key'],
273
- 'value' => $month_enddate,
274
- 'compare' => '<',
275
- 'type' => 'DATETIME'
276
- )
277
- );
278
- }
279
-
280
- $atts = apply_filters( 'ecs_atts_pre_query', $atts, $meta_date_date, $meta_date_compare );
281
- $args = apply_filters( 'ecs_get_events_args', array(
 
282
  'post_status' => 'publish',
283
  'hide_upcoming' => true,
284
  'posts_per_page' => $atts['limit'],
285
- 'tax_query'=> $atts['event_tax'],
286
  // Likely want to revamp this logic and separate the ordering from the date filtering
287
  'meta_key' => ( ( trim( $atts['orderby'] ) and 'title' != $atts['orderby'] ) ? $atts['orderby'] : $atts['key'] ),
288
  'orderby' => ( $atts['orderby'] == 'title' ? 'title' : 'event_date' ),
@@ -291,176 +295,177 @@ class Events_Calendar_Shortcode
291
  'meta_query' => apply_filters( 'ecs_get_meta_query', array( $atts['meta_date'] ), $atts, $meta_date_date, $meta_date_compare ),
292
  ), $atts, $meta_date_date, $meta_date_compare );
293
 
294
- $posts = tribe_get_events( $args );
295
- $posts = apply_filters( 'ecs_filter_events_after_get', $posts, $atts );
296
-
297
- $ecs_last_event_count = 0;
298
- if ( $posts or apply_filters( 'ecs_always_show', false, $atts ) ) {
299
- $output = apply_filters( 'ecs_beginning_output', $output, $posts, $atts );
300
- $output .= apply_filters( 'ecs_start_tag', '<ul class="ecs-event-list">', $atts, count( (array) $posts ) );
301
- $atts['contentorder'] = explode( ',', $atts['contentorder'] );
302
-
303
- foreach( (array) $posts as $post_index => $post ) {
304
- setup_postdata( $post );
305
- $event_output = '';
306
- if ( apply_filters( 'ecs_skip_event', false, $atts, $post ) )
307
- continue;
308
- $ecs_last_event_count++;
309
- $category_slugs = array();
310
- $category_list = get_the_terms( $post, 'tribe_events_cat' );
311
- $featured_class = ( get_post_meta( get_the_ID(), '_tribe_featured', true ) ? ' ecs-featured-event' : '' );
312
- if ( is_array( $category_list ) ) {
313
- foreach ( (array) $category_list as $category ) {
314
- $category_slugs[] = ' ' . $category->slug . '_ecs_category';
315
- }
316
- }
317
- $event_output .= apply_filters( 'ecs_event_start_tag', '<li class="ecs-event' . implode( '', $category_slugs ) . $featured_class . apply_filters( 'ecs_event_classes', '', $atts, $post ) . '">', $atts, $post );
318
-
319
- // Put Values into $event_output
320
- foreach ( apply_filters( 'ecs_event_contentorder', $atts['contentorder'], $atts, $post ) as $contentorder ) {
321
- switch ( trim( $contentorder ) ) {
322
- case 'title':
323
- $event_output .= apply_filters( 'ecs_event_title_tag_start', '<h4 class="entry-title summary">', $atts, $post ) .
324
- apply_filters( 'ecs_event_list_title_link_start', '<a href="' . tribe_get_event_link() . '" rel="bookmark">', $atts, $post ) . apply_filters( 'ecs_event_list_title', get_the_title(), $atts, $post ) . apply_filters( 'ecs_event_list_title_link_end', '</a>', $atts, $post ) .
325
- apply_filters( 'ecs_event_title_tag_end', '</h4>', $atts, $post );
326
- break;
327
-
328
- case 'thumbnail':
329
- if ( self::isValid( $atts['thumb'] ) ) {
330
- $thumbWidth = is_numeric($atts['thumbwidth']) ? $atts['thumbwidth'] : '';
331
- $thumbHeight = is_numeric($atts['thumbheight']) ? $atts['thumbheight'] : '';
332
- if( !empty( $thumbWidth ) && !empty( $thumbHeight ) ) {
333
- $event_output .= apply_filters( 'ecs_event_thumbnail', get_the_post_thumbnail( get_the_ID(), apply_filters( 'ecs_event_thumbnail_size', array( $thumbWidth, $thumbHeight ), $atts, $post ) ), $atts, $post );
334
- } else {
335
- if ( $thumb = get_the_post_thumbnail( get_the_ID(), apply_filters( 'ecs_event_thumbnail_size', ( trim( $atts['thumbsize'] ) ? trim( $atts['thumbsize'] ) : 'medium' ), $atts, $post ) ) ) {
336
- $event_output .= apply_filters( 'ecs_event_thumbnail_link_start', '<a href="' . tribe_get_event_link() . '">', $atts, $post );
337
- $event_output .= apply_filters( 'ecs_event_thumbnail', $thumb, $atts, $post );
338
- $event_output .= apply_filters( 'ecs_event_thumbnail_link_end', '</a>', $atts, $post );
339
- }
340
- }
341
- }
342
- break;
343
-
344
- case 'excerpt':
345
- if ( self::isValid( $atts['excerpt'] ) ) {
346
- $excerptLength = is_numeric( $atts['excerpt'] ) ? intval( $atts['excerpt'] ) : 100;
347
- $event_output .= apply_filters( 'ecs_event_excerpt_tag_start', '<p class="ecs-excerpt">', $atts, $post ) .
348
- apply_filters( 'ecs_event_excerpt', self::get_excerpt( $excerptLength ), $atts, $post, $excerptLength ) .
349
- apply_filters( 'ecs_event_excerpt_tag_end', '</p>', $atts, $post );
350
- }
351
- break;
352
-
353
- case 'date':
354
- if ( self::isValid( $atts['eventdetails'] ) ) {
355
- $event_output .= apply_filters( 'ecs_event_date_tag_start', '<span class="duration time">', $atts, $post ) .
356
- apply_filters( 'ecs_event_list_details', tribe_events_event_schedule_details(), $atts, $post ) .
357
- apply_filters( 'ecs_event_date_tag_end', '</span>', $atts, $post );
358
- }
359
- break;
360
-
361
- case 'venue':
362
- if ( self::isValid( $atts['venue'] ) and function_exists( 'tribe_has_venue' ) and tribe_has_venue() ) {
363
- $event_output .= apply_filters( 'ecs_event_venue_tag_start', '<span class="duration venue">', $atts, $post ) .
364
- apply_filters( 'ecs_event_venue_at_tag_start', '<em> ', $atts, $post ) .
365
- apply_filters( 'ecs_event_venue_at_text', __( 'at', 'the-events-calendar-shortcode' ), $atts, $post ) .
366
- apply_filters( 'ecs_event_venue_at_tag_end', ' </em>', $atts, $post ) .
367
- apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts, $post ) .
368
- apply_filters( 'ecs_event_venue_tag_end', '</span>', $atts, $post );
369
- }
370
- break;
371
- case 'date_thumb':
372
- if ( self::isValid( $atts['eventdetails'] ) ) {
373
- $event_output .= apply_filters( 'ecs_event_date_thumb', '<div class="date_thumb"><div class="month">' . tribe_get_start_date( null, false, 'M' ) . '</div><div class="day">' . tribe_get_start_date( null, false, 'j' ) . '</div></div>', $atts, $post );
374
- }
375
- break;
376
- default:
377
- $event_output .= apply_filters( 'ecs_event_list_output_custom_' . strtolower( trim( $contentorder ) ), '', $atts, $post );
378
- }
379
- }
380
- $event_output .= apply_filters( 'ecs_event_end_tag', '</li>', $atts, $post );
381
- $output .= apply_filters( 'ecs_single_event_output', $event_output, $atts, $post, $post_index, $posts );
382
- }
383
- $output .= apply_filters( 'ecs_end_tag', '</ul>', $atts );
384
- $output = apply_filters( 'ecs_ending_output', $output, $posts, $atts );
385
-
386
- if( self::isValid( $atts['viewall'] ) ) {
387
- $output .= apply_filters( 'ecs_view_all_events_tag_start', '<span class="ecs-all-events">', $atts ) .
388
- '<a href="' . apply_filters( 'ecs_event_list_viewall_link', tribe_get_events_link(), $atts ) .'" rel="bookmark">' . apply_filters( 'ecs_view_all_events_text', sprintf( __( 'View All %s', 'the-events-calendar' ), tribe_get_event_label_plural() ), $atts ) . '</a>';
389
- $output .= apply_filters( 'ecs_view_all_events_tag_end', '</span>' );
390
- }
391
-
392
- } else { //No Events were Found
393
- $output .= '<div class="ecs-no-events">' . apply_filters( 'ecs_no_events_found_message', sprintf( translate( $atts['message'], 'the-events-calendar' ), tribe_get_event_label_plural_lowercase() ), $atts ) . '</div>';
394
- } // endif
395
-
396
- wp_reset_postdata();
397
-
398
- return $output;
399
- }
400
-
401
- public function add_ecs_link( $output, $posts, $atts ) {
402
- if ( ! apply_filters( 'ecs_show_upgrades', true ) ) {
403
  return $output;
404
  }
405
- $output .= "<!--\n Event listing powered by The Events Calendar Shortcode\n https://eventcalendarnewsletter.com/the-events-calendar-shortcode/ \n-->";
406
- if ( ! get_option( 'ecs-show-link', false ) ) {
407
- return $output;
408
- }
409
- $output .= '<p class="ecs-powered-by-link">';
410
- $output .= sprintf( esc_html__( 'Event listing powered by %sThe Events Calendar Shortcode%s', 'the-events-calendar-shortcode' ), '<a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode/?utm_source=footer&utm_campaign=powered-by-link">', '</a>' );
411
- $output .= '</p>';
412
- return $output;
413
- }
414
-
415
- public function add_event_schema_json( $output, $posts, $atts ) {
416
- if ( self::isValid( $atts['schema'] ) and $posts and class_exists( 'Tribe__Events__JSON_LD__Event' ) and ( ! defined( 'DOING_AJAX' ) or ! DOING_AJAX ) )
417
- $output .= Tribe__Events__JSON_LD__Event::instance()->get_markup( $posts );
418
- return $output;
419
- }
420
-
421
- /**
422
- * Checks if the plugin attribute is valid
423
- *
424
- * @since 1.0.5
425
- *
426
- * @param string $prop
427
- * @return boolean
428
- */
429
- public static function isValid( $prop )
430
- {
431
- return ( $prop !== 'false' );
432
- }
433
-
434
- /**
435
- * Fetch and trims the excerpt to specified length
436
- *
437
- * @param integer $limit Characters to show
438
- * @param string $source content or excerpt
439
- *
440
- * @return string
441
- */
442
- public static function get_excerpt( $limit, $source = null )
443
- {
444
- $excerpt = get_the_excerpt();
445
- if( $source == "content" ) {
446
- $excerpt = get_the_content();
447
- }
448
-
449
- $excerpt = preg_replace( " (\[.*?\])", '', $excerpt );
450
- $excerpt = strip_tags( strip_shortcodes($excerpt) );
451
- $excerpt = trim( preg_replace( '/\s+/', ' ', $excerpt ) );
452
- if ( strlen( $excerpt ) > $limit ) {
453
- $excerpt = substr( $excerpt, 0, $limit );
454
- $excerpt .= '...';
455
- }
456
-
457
- return $excerpt;
458
- }
459
- }
460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  }
462
 
463
- /**
464
  * Instantiate the main class
465
  *
466
  * @since 1.0.0
3
  Plugin Name: The Events Calendar Shortcode & Block
4
  Plugin URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
5
  Description: An addon to add shortcode and new editor block functionality for The Events Calendar Plugin by Modern Tribe.
6
+ Version: 2.5.3
7
  Author: Event Calendar Newsletter
8
  Author URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode
9
  Contributors: brianhogg
14
 
15
  // Avoid direct calls to this file
16
  if ( !defined( 'ABSPATH' ) ) {
17
+ header( 'Status: 403 Forbidden' );
18
+ header( 'HTTP/1.1 403 Forbidden' );
19
+ exit();
20
  }
21
 
22
  define( 'TECS_CORE_PLUGIN_FILE', __FILE__ );
26
 
27
  // Check plugin requirements before loading plugin.
28
  $this_plugin_checks = new TECS_WP_Requirements( 'The Events Calendar Shortcode', plugin_basename( TECS_CORE_PLUGIN_FILE ), array(
29
+ 'PHP' => '5.3.3',
30
+ 'WordPress' => '4.1',
31
  'Extensions' => array(
32
  ),
33
  ) );
34
  if ( $this_plugin_checks->pass() === false ) {
35
  $this_plugin_checks->halt();
36
+
37
  return;
38
  }
39
 
40
  include_once dirname( TECS_CORE_PLUGIN_FILE ) . '/includes/ajax-endpoints.php';
41
  include_once dirname( TECS_CORE_PLUGIN_FILE ) . '/includes/notices/discounts.php';
42
 
43
+ /*
44
  * Events calendar shortcode addon main class
45
  *
46
  * @package events-calendar-shortcode
47
  * @author Brian Hogg
 
48
  */
49
 
50
  if ( ! class_exists( 'Events_Calendar_Shortcode' ) ) {
51
+ class Events_Calendar_Shortcode {
52
+
53
+ /**
54
+ * Current version of the plugin.
55
+ *
56
+ * @since 1.0.0
57
+ */
58
+ const VERSION = '2.5.3';
59
+
60
+ private $admin_page = null;
61
+
62
+ const MENU_SLUG = 'ecs-admin';
63
+
64
+ /**
65
+ * Constructor. Hooks all interactions to initialize the class.
66
+ *
67
+ * @since 1.0.0
68
+ * @see add_shortcode()
69
+ */
70
+ public function __construct() {
71
+ add_action( 'plugins_loaded', array( $this, 'verify_tec_installed' ), 2 );
72
+ add_action( 'admin_menu', array( $this, 'add_menu_page' ), 1000 );
73
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_action_links' ) );
74
+ add_shortcode( 'ecs-list-events', array( $this, 'ecs_fetch_events' ) );
75
+ add_filter( 'ecs_ending_output', array( $this, 'add_event_schema_json' ), 10, 3 );
76
+ add_filter( 'ecs_ending_output', array( $this, 'add_ecs_link' ), 10, 3 );
77
+ add_action( 'plugins_loaded', array( $this, 'load_languages' ) );
78
+ }
79
+
80
+ // END __construct()
81
+
82
+ public function load_languages() {
83
+ if ( function_exists( 'tecsp_load_textdomain' ) ) {
84
+ return;
85
+ }
86
+ load_plugin_textdomain( 'the-events-calendar-shortcode', false, plugin_basename( __DIR__ ) . '/languages' );
87
+ }
88
+
89
+ public function verify_tec_installed() {
90
+ if ( ! class_exists( 'Tribe__Events__Main' ) or ! defined( 'Tribe__Events__Main::VERSION' ) ) {
91
+ add_action( 'admin_notices', array( $this, 'show_tec_not_installed_message' ) );
92
+ }
93
+ }
94
+
95
+ public function show_tec_not_installed_message() {
96
+ if ( current_user_can( 'activate_plugins' ) ) {
97
+ $url = 'plugin-install.php?s=the+events+calendar&tab=search&type=term';
98
+ $title = __( 'The Events Calendar', 'tribe-events-ical-importer' );
99
+ echo '<div class="error"><p>' . sprintf( esc_html( __( 'To begin using %s, please install the latest version of %s%s%s and add an event.', 'the-events-calendar-shortcode' ) ), 'The Events Calendar Shortcode', '<a href="' . esc_url( admin_url( $url ) ) . '" title="' . esc_attr( $title ) . '">', 'The Events Calendar', '</a>' ) . '</p></div>';
100
+ }
101
+ }
102
+
103
+ public function add_menu_page() {
104
+ if ( ! class_exists( 'Tribe__Settings' ) or ! method_exists( Tribe__Settings::instance(), 'should_setup_pages' ) or ! Tribe__Settings::instance()->should_setup_pages() ) {
105
+ return;
106
+ }
107
 
108
+ $page_title = $menu_title = esc_html__( 'Shortcode & Block', 'the-events-calendar-shortcode' );
109
+ $capability = apply_filters( 'ecs_admin_page_capability', 'install_plugins' );
110
+
111
+ $where = Tribe__Settings::instance()->get_parent_slug();
112
+
113
+ $this->admin_page = add_submenu_page( $where, $page_title, $menu_title, $capability, self::MENU_SLUG, array( $this, 'do_menu_page' ) );
114
+
115
+ add_action( 'admin_print_styles-' . $this->admin_page, array( $this, 'enqueue' ) );
116
+ add_action( 'admin_print_styles', array( $this, 'enqueue_submenu_style' ) );
117
+ }
118
+
119
+ public function enqueue() {
120
+ wp_enqueue_style( 'ecs-admin-css', plugins_url( 'static/ecs-admin.css', __FILE__ ), array(), self::VERSION );
121
+ wp_enqueue_script( 'ecs-admin-js', plugins_url( 'static/ecs-admin.min.js', __FILE__ ), array(), self::VERSION );
122
+ }
123
+
124
+ /**
125
+ * Function to add a small CSS file to add some colour to the Shortcode submenu item
126
+ */
127
+ public function enqueue_submenu_style() {
128
+ wp_enqueue_style( 'ecs-submenu-css', plugins_url( 'static/ecs-submenu.css', __FILE__ ), array(), self::VERSION );
129
+ }
130
+
131
+ public function do_menu_page() {
132
+ include __DIR__ . '/templates/admin-page.php';
133
+ }
134
+
135
+ public function add_action_links( $links ) {
136
+ $mylinks = array();
137
+ if ( class_exists( 'Tribe__Settings' ) and method_exists( Tribe__Settings::instance(), 'should_setup_pages' ) and Tribe__Settings::instance()->should_setup_pages() ) {
138
+ $mylinks[] = '<a href="' . admin_url( 'edit.php?post_type=tribe_events&page=ecs-admin' ) . '">' . esc_html__( 'Settings', 'the-events-calendar-shortcode' ) . '</a>';
139
+ }
140
+ $mylinks[] = '<a target="_blank" style="color:#3db634; font-weight: bold;" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode/?utm_source=plugin-list&utm_medium=upgrade-link&utm_campaign=plugin-list&utm_content=action-link">' . esc_html__( 'Upgrade', 'the-events-calendar-shortcode' ) . '</a>';
141
+
142
+ return array_merge( $links, $mylinks );
143
+ }
144
+
145
+ /**
146
+ * Fetch and return required events.
147
+ *
148
+ * @param array $atts shortcode attributes
149
+ *
150
+ * @return string shortcode output
151
+ */
152
+ public function ecs_fetch_events( $atts ) {
153
+ /*
154
+ * Check if events calendar plugin method exists
155
+ */
156
+ if ( !function_exists( 'tribe_get_events' ) ) {
157
+ return '';
158
+ }
159
+
160
+ global $post, $ecs_last_event_count;
161
+ $output = '';
162
+
163
+ $atts = shortcode_atts( apply_filters( 'ecs_shortcode_atts', array(
164
+ 'cat' => '',
165
+ 'month' => '',
166
+ 'limit' => 5,
167
+ 'eventdetails' => 'true',
168
+ 'time' => null,
169
+ 'past' => null,
170
+ 'venue' => 'false',
171
+ 'author' => null,
172
+ 'schema' => 'true',
173
+ 'message' => 'There are no upcoming %s at this time.',
174
+ 'key' => 'End Date',
175
+ 'order' => 'ASC',
176
+ 'orderby' => 'startdate',
177
+ 'viewall' => 'false',
178
+ 'excerpt' => 'false',
179
+ 'thumb' => 'false',
180
+ 'thumbsize' => '',
181
+ 'thumbwidth' => '',
182
+ 'thumbheight' => '',
183
+ 'contentorder' => apply_filters( 'ecs_default_contentorder', 'title, thumbnail, excerpt, date, venue', $atts ),
184
+ 'event_tax' => '',
185
+ ), $atts ), $atts, 'ecs-list-events' );
186
+
187
+ // Category
188
+ if ( $atts['cat'] ) {
189
+ if ( strpos( $atts['cat'], ',' ) !== false ) {
190
+ $atts['cats'] = explode( ',', $atts['cat'] );
191
+ $atts['cats'] = array_map( 'trim', $atts['cats'] );
192
+ } else {
193
+ $atts['cats'] = array( trim( $atts['cat'] ) );
194
+ }
195
+
196
+ $atts['event_tax'] = array(
197
+ 'relation' => 'OR',
198
+ );
199
+
200
+ foreach ( $atts['cats'] as $cat ) {
201
+ $atts['event_tax'][] = array(
202
+ 'relation' => 'OR',
203
+ array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  'taxonomy' => 'tribe_events_cat',
205
  'field' => 'name',
206
  'terms' => $cat,
209
  'taxonomy' => 'tribe_events_cat',
210
  'field' => 'slug',
211
  'terms' => $cat,
212
+ ),
213
  );
214
+ }
215
+ }
216
+
217
+ // Past Event
218
+ $meta_date_compare = '>=';
219
+ $meta_date_date = current_time( 'Y-m-d H:i:s' );
220
+
221
+ if ( $atts['time'] == 'past' || !empty( $atts['past'] ) ) {
222
+ $meta_date_compare = '<';
223
+ }
224
+
225
+ // Key, used in filtering events by date
226
+ if ( str_replace( ' ', '', trim( strtolower( $atts['key'] ) ) ) == 'startdate' ) {
227
+ $atts['key'] = '_EventStartDate';
228
+ } else {
229
+ $atts['key'] = '_EventEndDate';
230
+ }
231
+
232
+ // Orderby
233
+ if ( str_replace( ' ', '', trim( strtolower( $atts['orderby'] ) ) ) == 'enddate' ) {
234
+ $atts['orderby'] = '_EventEndDate';
235
+ } elseif ( trim( strtolower( $atts['orderby'] ) ) == 'title' ) {
236
+ $atts['orderby'] = 'title';
237
+ } else {
238
+ $atts['orderby'] = '_EventStartDate';
239
+ }
240
+
241
+ // Date
242
+ $atts['meta_date'] = array(
243
+ array(
244
+ 'key' => $atts['key'],
245
+ 'value' => $meta_date_date,
246
+ 'compare' => $meta_date_compare,
247
+ 'type' => 'DATETIME',
248
+ ),
249
+ );
250
+
251
+ // Specific Month
252
+ if ( 'current' == $atts['month'] ) {
253
+ $atts['month'] = current_time( 'Y-m' );
254
+ }
255
+ if ( 'next' == $atts['month'] ) {
256
+ $now = current_datetime();
257
+ $atts['month'] = $now->modify( 'first day of this month' )->modify( 'first day of next month' )->format( 'Y-m' );
258
+ }
259
+ if ( $atts['month'] ) {
260
+ $month_array = explode( '-', $atts['month'] );
261
+
262
+ $month_yearstr = $month_array[0];
263
+ $month_monthstr = $month_array[1];
264
+ $month_startdate = date( 'Y-m-d', strtotime( $month_yearstr . '-' . $month_monthstr . '-01' ) );
265
+ $month_enddate = date( 'Y-m-01', strtotime( '+1 month', strtotime( $month_startdate ) ) );
266
+
267
+ $atts['meta_date'] = array(
268
+ 'relation' => 'AND',
269
+ array(
270
+ 'key' => $atts['key'],
271
+ 'value' => $month_startdate,
272
+ 'compare' => '>=',
273
+ 'type' => 'DATETIME',
274
+ ),
275
+ array(
276
+ 'key' => $atts['key'],
277
+ 'value' => $month_enddate,
278
+ 'compare' => '<',
279
+ 'type' => 'DATETIME',
280
+ ),
281
+ );
282
+ }
283
+
284
+ $atts = apply_filters( 'ecs_atts_pre_query', $atts, $meta_date_date, $meta_date_compare );
285
+ $args = apply_filters( 'ecs_get_events_args', array(
286
  'post_status' => 'publish',
287
  'hide_upcoming' => true,
288
  'posts_per_page' => $atts['limit'],
289
+ 'tax_query' => $atts['event_tax'],
290
  // Likely want to revamp this logic and separate the ordering from the date filtering
291
  'meta_key' => ( ( trim( $atts['orderby'] ) and 'title' != $atts['orderby'] ) ? $atts['orderby'] : $atts['key'] ),
292
  'orderby' => ( $atts['orderby'] == 'title' ? 'title' : 'event_date' ),
295
  'meta_query' => apply_filters( 'ecs_get_meta_query', array( $atts['meta_date'] ), $atts, $meta_date_date, $meta_date_compare ),
296
  ), $atts, $meta_date_date, $meta_date_compare );
297
 
298
+ $posts = tribe_get_events( $args );
299
+ $posts = apply_filters( 'ecs_filter_events_after_get', $posts, $atts );
300
+
301
+ $ecs_last_event_count = 0;
302
+ if ( $posts or apply_filters( 'ecs_always_show', false, $atts ) ) {
303
+ $output = apply_filters( 'ecs_beginning_output', $output, $posts, $atts );
304
+ $output .= apply_filters( 'ecs_start_tag', '<ul class="ecs-event-list">', $atts, count( (array) $posts ) );
305
+ $atts['contentorder'] = explode( ',', $atts['contentorder'] );
306
+
307
+ foreach ( (array) $posts as $post_index => $post ) {
308
+ setup_postdata( $post );
309
+ $event_output = '';
310
+ if ( apply_filters( 'ecs_skip_event', false, $atts, $post ) ) {
311
+ continue;
312
+ }
313
+ $ecs_last_event_count++;
314
+ $category_slugs = array();
315
+ $category_list = get_the_terms( $post, 'tribe_events_cat' );
316
+ $featured_class = ( get_post_meta( get_the_ID(), '_tribe_featured', true ) ? ' ecs-featured-event' : '' );
317
+ if ( is_array( $category_list ) ) {
318
+ foreach ( (array) $category_list as $category ) {
319
+ $category_slugs[] = ' ' . $category->slug . '_ecs_category';
320
+ }
321
+ }
322
+ $event_output .= apply_filters( 'ecs_event_start_tag', '<li class="ecs-event' . implode( '', $category_slugs ) . $featured_class . apply_filters( 'ecs_event_classes', '', $atts, $post ) . '">', $atts, $post );
323
+
324
+ // Put Values into $event_output
325
+ foreach ( apply_filters( 'ecs_event_contentorder', $atts['contentorder'], $atts, $post ) as $contentorder ) {
326
+ switch ( trim( $contentorder ) ) {
327
+ case 'title':
328
+ $event_output .= apply_filters( 'ecs_event_title_tag_start', '<h4 class="entry-title summary">', $atts, $post ) .
329
+ apply_filters( 'ecs_event_list_title_link_start', '<a href="' . tribe_get_event_link() . '" rel="bookmark">', $atts, $post ) . apply_filters( 'ecs_event_list_title', get_the_title(), $atts, $post ) . apply_filters( 'ecs_event_list_title_link_end', '</a>', $atts, $post ) .
330
+ apply_filters( 'ecs_event_title_tag_end', '</h4>', $atts, $post );
331
+ break;
332
+
333
+ case 'thumbnail':
334
+ if ( self::isValid( $atts['thumb'] ) ) {
335
+ $thumbWidth = is_numeric( $atts['thumbwidth'] ) ? $atts['thumbwidth'] : '';
336
+ $thumbHeight = is_numeric( $atts['thumbheight'] ) ? $atts['thumbheight'] : '';
337
+ if ( !empty( $thumbWidth ) && !empty( $thumbHeight ) ) {
338
+ $event_output .= apply_filters( 'ecs_event_thumbnail', get_the_post_thumbnail( get_the_ID(), apply_filters( 'ecs_event_thumbnail_size', array( $thumbWidth, $thumbHeight ), $atts, $post ) ), $atts, $post );
339
+ } else {
340
+ if ( $thumb = get_the_post_thumbnail( get_the_ID(), apply_filters( 'ecs_event_thumbnail_size', ( trim( $atts['thumbsize'] ) ? trim( $atts['thumbsize'] ) : 'medium' ), $atts, $post ) ) ) {
341
+ $event_output .= apply_filters( 'ecs_event_thumbnail_link_start', '<a href="' . tribe_get_event_link() . '">', $atts, $post );
342
+ $event_output .= apply_filters( 'ecs_event_thumbnail', $thumb, $atts, $post );
343
+ $event_output .= apply_filters( 'ecs_event_thumbnail_link_end', '</a>', $atts, $post );
344
+ }
345
+ }
346
+ }
347
+ break;
348
+
349
+ case 'excerpt':
350
+ if ( self::isValid( $atts['excerpt'] ) ) {
351
+ $excerptLength = is_numeric( $atts['excerpt'] ) ? intval( $atts['excerpt'] ) : 100;
352
+ $event_output .= apply_filters( 'ecs_event_excerpt_tag_start', '<p class="ecs-excerpt">', $atts, $post ) .
353
+ apply_filters( 'ecs_event_excerpt', self::get_excerpt( $excerptLength ), $atts, $post, $excerptLength ) .
354
+ apply_filters( 'ecs_event_excerpt_tag_end', '</p>', $atts, $post );
355
+ }
356
+ break;
357
+
358
+ case 'date':
359
+ if ( self::isValid( $atts['eventdetails'] ) ) {
360
+ $event_output .= apply_filters( 'ecs_event_date_tag_start', '<span class="duration time">', $atts, $post ) .
361
+ apply_filters( 'ecs_event_list_details', tribe_events_event_schedule_details(), $atts, $post ) .
362
+ apply_filters( 'ecs_event_date_tag_end', '</span>', $atts, $post );
363
+ }
364
+ break;
365
+
366
+ case 'venue':
367
+ if ( self::isValid( $atts['venue'] ) and function_exists( 'tribe_has_venue' ) and tribe_has_venue() ) {
368
+ $event_output .= apply_filters( 'ecs_event_venue_tag_start', '<span class="duration venue">', $atts, $post ) .
369
+ apply_filters( 'ecs_event_venue_at_tag_start', '<em> ', $atts, $post ) .
370
+ apply_filters( 'ecs_event_venue_at_text', __( 'at', 'the-events-calendar-shortcode' ), $atts, $post ) .
371
+ apply_filters( 'ecs_event_venue_at_tag_end', ' </em>', $atts, $post ) .
372
+ apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts, $post ) .
373
+ apply_filters( 'ecs_event_venue_tag_end', '</span>', $atts, $post );
374
+ }
375
+ break;
376
+ case 'date_thumb':
377
+ if ( self::isValid( $atts['eventdetails'] ) ) {
378
+ $event_output .= apply_filters( 'ecs_event_date_thumb', '<div class="date_thumb"><div class="month">' . tribe_get_start_date( null, false, 'M' ) . '</div><div class="day">' . tribe_get_start_date( null, false, 'j' ) . '</div></div>', $atts, $post );
379
+ }
380
+ break;
381
+ default:
382
+ $event_output .= apply_filters( 'ecs_event_list_output_custom_' . strtolower( trim( $contentorder ) ), '', $atts, $post );
383
+ }
384
+ }
385
+ $event_output .= apply_filters( 'ecs_event_end_tag', '</li>', $atts, $post );
386
+ $output .= apply_filters( 'ecs_single_event_output', $event_output, $atts, $post, $post_index, $posts );
387
+ }
388
+ $output .= apply_filters( 'ecs_end_tag', '</ul>', $atts );
389
+ $output = apply_filters( 'ecs_ending_output', $output, $posts, $atts );
390
+
391
+ if ( self::isValid( $atts['viewall'] ) ) {
392
+ $output .= apply_filters( 'ecs_view_all_events_tag_start', '<span class="ecs-all-events">', $atts ) .
393
+ '<a href="' . apply_filters( 'ecs_event_list_viewall_link', tribe_get_events_link(), $atts ) . '" rel="bookmark">' . apply_filters( 'ecs_view_all_events_text', sprintf( __( 'View All %s', 'the-events-calendar' ), tribe_get_event_label_plural() ), $atts ) . '</a>';
394
+ $output .= apply_filters( 'ecs_view_all_events_tag_end', '</span>' );
395
+ }
396
+ } else { //No Events were Found
397
+ $output .= '<div class="ecs-no-events">' . apply_filters( 'ecs_no_events_found_message', sprintf( translate( $atts['message'], 'the-events-calendar' ), tribe_get_event_label_plural_lowercase() ), $atts ) . '</div>';
398
+ } // endif
399
+
400
+ wp_reset_postdata();
401
+
 
 
 
 
 
402
  return $output;
403
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
 
405
+ public function add_ecs_link( $output, $posts, $atts ) {
406
+ if ( ! apply_filters( 'ecs_show_upgrades', true ) ) {
407
+ return $output;
408
+ }
409
+ $output .= "<!--\n Event listing powered by The Events Calendar Shortcode\n https://eventcalendarnewsletter.com/the-events-calendar-shortcode/ \n-->";
410
+ if ( ! get_option( 'ecs-show-link', false ) ) {
411
+ return $output;
412
+ }
413
+ $output .= '<p class="ecs-powered-by-link">';
414
+ $output .= sprintf( esc_html__( 'Event listing powered by %sThe Events Calendar Shortcode%s', 'the-events-calendar-shortcode' ), '<a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode/?utm_source=footer&utm_campaign=powered-by-link">', '</a>' );
415
+ $output .= '</p>';
416
+
417
+ return $output;
418
+ }
419
+
420
+ public function add_event_schema_json( $output, $posts, $atts ) {
421
+ if ( self::isValid( $atts['schema'] ) and $posts and class_exists( 'Tribe__Events__JSON_LD__Event' ) and ( ! defined( 'DOING_AJAX' ) or ! DOING_AJAX ) ) {
422
+ $output .= Tribe__Events__JSON_LD__Event::instance()->get_markup( $posts );
423
+ }
424
+
425
+ return $output;
426
+ }
427
+
428
+ /**
429
+ * Checks if the plugin attribute is valid
430
+ *
431
+ * @since 1.0.5
432
+ *
433
+ * @param string $prop
434
+ *
435
+ * @return bool
436
+ */
437
+ public static function isValid( $prop ) {
438
+ return $prop !== 'false';
439
+ }
440
+
441
+ /**
442
+ * Fetch and trims the excerpt to specified length
443
+ *
444
+ * @param int $limit Characters to show
445
+ * @param string $source content or excerpt
446
+ *
447
+ * @return string
448
+ */
449
+ public static function get_excerpt( $limit, $source = null ) {
450
+ $excerpt = get_the_excerpt();
451
+ if ( $source == 'content' ) {
452
+ $excerpt = get_the_content();
453
+ }
454
+
455
+ $excerpt = preg_replace( " (\[.*?\])", '', $excerpt );
456
+ $excerpt = strip_tags( strip_shortcodes( $excerpt ) );
457
+ $excerpt = trim( preg_replace( '/\s+/', ' ', $excerpt ) );
458
+ if ( strlen( $excerpt ) > $limit ) {
459
+ $excerpt = substr( $excerpt, 0, $limit );
460
+ $excerpt .= '...';
461
+ }
462
+
463
+ return $excerpt;
464
+ }
465
+ }
466
  }
467
 
468
+ /*
469
  * Instantiate the main class
470
  *
471
  * @since 1.0.0