The Events Calendar Shortcode - Version 1.3

Version Description

  • Fixes issue with "viewall" showing the events twice
  • Fixes time zone issue by using current_time() instead of date()
  • Hides events that are marked 'hide from listing'
  • Switches to tribe_get_events() to get the events
  • Removes the ... from the end of the excerpt if less than the excerpt length
  • Adds date_thumb option
  • Adds additional filters
Download this release

Release Info

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

Code changes from version 1.2 to 1.3

readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: brianhogg, dandelionweb, ankitpokhrel, sujin2f
3
  Tags: event, events, calendar, shortcode, modern tribe
4
  Requires at least: 4.0
5
- Tested up to: 4.6
6
- Stable tag: 1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -13,8 +13,9 @@ Adds shortcode functionality to The Events Calendar Plugin (Free Version) by Mod
13
 
14
  This plugin adds a shortcode for use with The Events Calendar Plugin (by Modern Tribe).
15
 
16
- The shortcode displays lists of your events. You can control the event display with the shortcode options.
17
- Example shortcode to show next 8 events in the category festival in ASC order with date showing [ecs-list-events cat='festival' limit='8']
 
18
 
19
  = Shortcode Options: =
20
  * Basic shortcode: [ecs-list-events]
@@ -24,7 +25,7 @@ Example shortcode to show next 8 events in the category festival in ASC order wi
24
  * date - To show or hide date. Value can be 'true' or 'false'. Default is true. [ecs-list-events eventdetails='false']
25
  * venue - To show or hide the venue. Value can be 'true' or 'false'. Default is false. [ecs-list-events venue='true']
26
  * excerpt - To show or hide the excerpt and set excerpt length. Default is false. [ecs-list-events excerpt='true'] //displays excerpt with length 100
27
- excerpt='300' //displays excerpt with length 300
28
  * thumb - To show or hide thumbnail image. Default is false. [ecs-list-events thumb='true'] //displays post thumbnail in default thumbnail dimension from media settings.
29
  * You can use 2 other attributes: thumbwidth and thumbheight to customize the thumbnail size [ecs-list-events thumb='true' thumbwidth='150' thumbheight='150']
30
  * message - Message to show when there are no events. Defaults to 'There are no upcoming events at this time.'
@@ -34,11 +35,14 @@ Example shortcode to show next 8 events in the category festival in ASC order wi
34
  * past - Show Outdated Events. [ecs-list-events cat='festival' past='yes']
35
  * key - Order with Start Date [ecs-list-events cat='festival' key='start date']
36
 
 
 
 
 
37
 
38
- Want to include your upcoming events in your newsletters?
39
-
40
- >**[Check out Event Calendar Newsletter](https://eventcalendarnewsletter.com/?utm_source=wordpress.org&utm_medium=link&utm_campaign=event-cal-shortcode-readme&utm_content=tecs-description)**
41
 
 
42
 
43
  == Installation ==
44
 
@@ -74,7 +78,8 @@ Want to include your upcoming events in your newsletters?
74
  * Not all themes support use of a shortcode in a widget. If a regular text widget doesn't work, put the shortcode in a <a href="https://wordpress.org/plugins/black-studio-tinymce-widget/">Visual Editor Widget</a>.
75
 
76
  = What are the classes for styling the list of events? =
77
- The plugin does not include styling. Events are listed in ul li tags with appropriate classes for styling.
 
78
  * ul class="ecs-event-list"
79
  * li class="ecs-event"
80
  * event title link is H4 class="entry-title summary"
@@ -83,10 +88,31 @@ The plugin does not include styling. Events are listed in ul li tags with approp
83
  * span .ecs-all-events
84
  * p .ecs-excerpt
85
 
 
 
86
  = How do I include a list of events in a page template? =
87
  include echo do_shortcode("[ecs-list-events]"); in the template where you want the events list to display.
88
 
 
 
 
 
 
 
89
  == Upgrade Notice ==
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  = 1.0.11 =
91
  Add Link to Thumbnail
92
  merge pull request from d4mation -Replaced extracted variables with $atts as using extract was deprecated
@@ -110,24 +136,37 @@ Fix missing ul
110
  * Initial Release
111
 
112
  == Changelog ==
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  = 1.0.11 =
114
  Add Link to Thumbnail
115
  merge pull request from d4mation -Replaced extracted variables with $atts as using extract was deprecated
116
- = 1.0.10 =
117
- Minor Error Change - fix name and slug
118
  = 1.0.9 =
119
  Minor Error Change - Multiple Categories
120
  = 1.0.8 =
121
  Add options : multi-categories - Thanks to sujin2f
122
  = 1.0.7 =
123
- * Add options : contentorder, month, past, key - Thanks to sujin2f
124
  = 1.0.6 =
125
  Fix missing ul
126
  = 1.0.5 =
127
  * Add excerpt and thumbnail - Thanks to ankitpokhrel
128
  = 1.0.2 =
129
- * Add venue to shortcode - Thanks to ankitpokhrel
130
  = 1.0.1 =
131
  * Fix Firefox browser compatibility issue
132
  = 1 =
133
- * Initial release
2
  Contributors: brianhogg, dandelionweb, ankitpokhrel, sujin2f
3
  Tags: event, events, calendar, shortcode, modern tribe
4
  Requires at least: 4.0
5
+ Tested up to: 4.7
6
+ Stable tag: 1.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
13
 
14
  This plugin adds a shortcode for use with The Events Calendar Plugin (by Modern Tribe).
15
 
16
+ With this plugin, just add the shortcode on a page to display a list of your events. For example to show next 8 events in the category festival:
17
+
18
+ [ecs-list-events cat="festival" limit="8"]
19
 
20
  = Shortcode Options: =
21
  * Basic shortcode: [ecs-list-events]
25
  * date - To show or hide date. Value can be 'true' or 'false'. Default is true. [ecs-list-events eventdetails='false']
26
  * venue - To show or hide the venue. Value can be 'true' or 'false'. Default is false. [ecs-list-events venue='true']
27
  * excerpt - To show or hide the excerpt and set excerpt length. Default is false. [ecs-list-events excerpt='true'] //displays excerpt with length 100
28
+ * excerpt='300' //displays excerpt with length 300
29
  * thumb - To show or hide thumbnail image. Default is false. [ecs-list-events thumb='true'] //displays post thumbnail in default thumbnail dimension from media settings.
30
  * You can use 2 other attributes: thumbwidth and thumbheight to customize the thumbnail size [ecs-list-events thumb='true' thumbwidth='150' thumbheight='150']
31
  * message - Message to show when there are no events. Defaults to 'There are no upcoming events at this time.'
35
  * past - Show Outdated Events. [ecs-list-events cat='festival' past='yes']
36
  * key - Order with Start Date [ecs-list-events cat='festival' key='start date']
37
 
38
+ = Pro Version Options: =
39
+ * hiderecurring - To only show the first instance of a recurring event, set to 'true'
40
+ * tag - Filter by one or more tags. Use commas when you want to filter by multiple tags.
41
+ * design - Shows improved design by default, or set to 'standard' for the regular one and 'compact' for a more compact listing
42
 
43
+ [Get the Pro Version](https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=wordpress.org&utm_medium=link&utm_campaign=tecs-readme&utm_content=description)
 
 
44
 
45
+ This plugin is not developed by or affiliated with The Events Calendar or Modern Tribe in any way.
46
 
47
  == Installation ==
48
 
78
  * Not all themes support use of a shortcode in a widget. If a regular text widget doesn't work, put the shortcode in a <a href="https://wordpress.org/plugins/black-studio-tinymce-widget/">Visual Editor Widget</a>.
79
 
80
  = What are the classes for styling the list of events? =
81
+ By default the plugin does not include styling. Events are listed in ul li tags with appropriate classes for styling.
82
+
83
  * ul class="ecs-event-list"
84
  * li class="ecs-event"
85
  * event title link is H4 class="entry-title summary"
88
  * span .ecs-all-events
89
  * p .ecs-excerpt
90
 
91
+ Want a better looking design? Check out [The Events Calendar Shortcode PRO](https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=wordpress.org&utm_medium=link&utm_campaign=tecs-readme-faq&utm_content=description)
92
+
93
  = How do I include a list of events in a page template? =
94
  include echo do_shortcode("[ecs-list-events]"); in the template where you want the events list to display.
95
 
96
+ == Screenshots ==
97
+
98
+ 1. After adding the plugin, add the shortcode where you want the list of events to appear in the page
99
+ 2. Events will appear in a list
100
+ 3. Many settings you can use in the shortcode to change what details appear in the events listing
101
+
102
  == Upgrade Notice ==
103
+
104
+ = 1.3 =
105
+ * Fixes issue with "viewall" showing the events twice
106
+ * Fixes time zone issue by using current_time() instead of date()
107
+ * Hides events that are marked 'hide from listing'
108
+ * Switches to tribe_get_events() to get the events
109
+ * Removes the ... from the end of the excerpt if less than the excerpt length
110
+ * Adds date_thumb option
111
+ * Adds additional filters
112
+
113
+ = 1.2 =
114
+ * Updates author/description (Event Calendar Newsletter / Brian Hogg Consulting)
115
+
116
  = 1.0.11 =
117
  Add Link to Thumbnail
118
  merge pull request from d4mation -Replaced extracted variables with $atts as using extract was deprecated
136
  * Initial Release
137
 
138
  == Changelog ==
139
+
140
+ = 1.3 =
141
+ * Fixes issue with "viewall" showing the events twice
142
+ * Fixes time zone issue by using current_time() instead of date()
143
+ * Hides events that are marked 'hide from listing'
144
+ * Switches to tribe_get_events() to get the events
145
+ * Removes the ... from the end of the excerpt if less than the excerpt length
146
+ * Adds date_thumb option
147
+ * Adds additional filters
148
+
149
+ = 1.2 =
150
+ * Updates author/description (Event Calendar Newsletter / Brian Hogg Consulting)
151
+
152
  = 1.0.11 =
153
  Add Link to Thumbnail
154
  merge pull request from d4mation -Replaced extracted variables with $atts as using extract was deprecated
155
+ =1.0.10 =
156
+ Minor Error Change - fix name and slug
157
  = 1.0.9 =
158
  Minor Error Change - Multiple Categories
159
  = 1.0.8 =
160
  Add options : multi-categories - Thanks to sujin2f
161
  = 1.0.7 =
162
+ Add options : contentorder, month, past, key - Thanks to sujin2f
163
  = 1.0.6 =
164
  Fix missing ul
165
  = 1.0.5 =
166
  * Add excerpt and thumbnail - Thanks to ankitpokhrel
167
  = 1.0.2 =
168
+ * Add venue to shortcode - Thanks to ankitpokhrel
169
  = 1.0.1 =
170
  * Fix Firefox browser compatibility issue
171
  = 1 =
172
+ * Initial Release
static/ecs-admin.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ td.styling { border-left: 1px solid #000; padding-left: 10px; }
2
+ td blockquote { font-family: monospace; }
static/ecs-admin.js ADDED
File without changes
static/ecs-submenu.css ADDED
@@ -0,0 +1 @@
 
1
+ #adminmenu #menu-posts-tribe_events .wp-submenu li:last-child a { color: #f77530; }
templates/admin-page.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+ <h2><?php _e( 'The Events Calendar Shortcode' ); ?></h2>
3
+
4
+ <p>The shortcode displays lists of your events. For example to shortcode to show next 8 events in the category festival in ASC order with date showing:</p>
5
+
6
+ <pre>[ecs-list-events cat='festival' limit='8']</pre>
7
+
8
+
9
+
10
+ <table>
11
+ <tbody>
12
+ <tr valign="top">
13
+ <td valign="top">
14
+ <h3>Shortcode Options</h3>
15
+
16
+ <div>
17
+ <h4>Basic shortcode</h4>
18
+ <blockquote>[ecs-list-events]</blockquote>
19
+
20
+ <?php do_action( 'ecs_admin_page_options_before' ); ?>
21
+
22
+ <h4>cat</h4>
23
+ <p>Represents single event category. Use commas when you want multiple categories
24
+ <blockquote>[ecs-list-events cat='festival']</blockquote>
25
+ <blockquote>[ecs-list-events cat='festival, workshops']</blockquote>
26
+
27
+ <?php do_action( 'ecs_admin_page_options_after_cat' ); ?>
28
+
29
+ <h4>limit</h4>
30
+ <p>Total number of events to show. Default is 5.</p>
31
+ <blockquote>[ecs-list-events limit='3']</blockquote>
32
+ <h4>order</h4>
33
+ <p>Order of the events to be shown. Value can be 'ASC' or 'DESC'. Default is 'ASC'. Order is based on event date.</p>
34
+ <blockquote>[ecs-list-events order='DESC']</blockquote>
35
+ <h4>date</h4>
36
+ <p>To show or hide date. Value can be 'true' or 'false'. Default is true.</p>
37
+ <blockquote>[ecs-list-events eventdetails='false']</blockquote>
38
+ <h4>venue</h4>
39
+ <p>To show or hide the venue. Value can be 'true' or 'false'. Default is false.</p>
40
+ <blockquote>[ecs-list-events venue='true']</blockquote>
41
+ <h4>excerpt</h4>
42
+ <p>To show or hide the excerpt and set excerpt length. Default is false.<p>
43
+ <blockquote>[ecs-list-events excerpt='true']</blockquote>
44
+ <blockquote>[ecs-list-events excerpt='300']</blockquote>
45
+ <h4>thumb</h4>
46
+ <p>To show or hide thumbnail/featured image. Default is false.</p>
47
+ <blockquote>[ecs-list-events thumb='true']</blockquote>
48
+ <p>You can use 2 other attributes: thumbwidth and thumbheight to customize the thumbnail size</p>
49
+ <blockquote>[ecs-list-events thumb='true' thumbwidth='150' thumbheight='150']</blockquote>
50
+ <h4>message</h4>
51
+ <p>Message to show when there are no events. Defaults to 'There are no upcoming events at this time.'</p>
52
+ <h4>viewall</h4>
53
+ <p>Determines whether to show 'View all events' or not. Values can be 'true' or 'false'. Default to 'true'</p>
54
+ <blockquote>[ecs-list-events cat='festival' limit='3' order='DESC' viewall='false']</blockquote>
55
+ <h4>contentorder</h4>
56
+ <p>Manage the order of content with commas. Default to title, thumbnail, excerpt, date, venue.</p>
57
+ <blockquote>[ecs-list-events cat='festival' limit='3' order='DESC' viewall='false' contentorder='title, thumbnail, excerpt, date, venue']</blockquote>
58
+ <h4>month</h4>
59
+ <p>Show only specific Month. Type 'current' for displaying current month only, ie:</p>
60
+ <blockquote>[ecs-list-events cat='festival' month='2015-06']</blockquote>
61
+ <h4>past</h4>
62
+ <p>Show outdated events (ie. events that have already happened)</p>
63
+ <blockquote>[ecs-list-events cat='festival' past='yes']</blockquote>
64
+ <h4>key</h4>
65
+ <p>Order with start date</p>
66
+ <blockquote>[ecs-list-events cat='festival' key='start date']</blockquote>
67
+
68
+ <?php do_action( 'ecs_admin_page_options_after' ); ?>
69
+
70
+ </div>
71
+
72
+ </td>
73
+ <td valign="top" class="styling">
74
+ <h3>Styling/Design</h3>
75
+
76
+ <?php do_action( 'ecs_admin_page_styling_before' ); ?>
77
+
78
+ <?php if ( apply_filters( 'ecs_show_upgrades', true ) ): ?>
79
+
80
+ <p>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:</p>
81
+
82
+ <ul>
83
+ <li>ul class="ecs-event-list"</li>
84
+ <li>li class="ecs-event"</li>
85
+ <li>event title link is H4 class="entry-title summary"</li>
86
+ <li>date class is time</li>
87
+ <li>venue class is venue</li>
88
+ <li>span .ecs-all-events</li>
89
+ <li>p .ecs-excerpt</li>
90
+ </ul>
91
+
92
+ <p><em>Want a better looking design without adding any CSS? Check out <a target="_blank" href="https://eventcalendarnewsletter.com/the-events-calendar-shortcode?utm_source=wordpress.org&utm_medium=link&utm_campaign=tecs-readme-faq&utm_content=description">The Events Calendar Shortcode PRO</a></em></p>
93
+ <?php endif; ?>
94
+ </td>
95
+ </tr>
96
+ </tbody>
97
+ </table>
98
+
99
+ <p><small>This plugin is not developed by or affiliated with The Events Calendar or Modern Tribe in any way.</small></p>
100
+ </div>
the-events-calendar-shortcode.php CHANGED
@@ -3,11 +3,10 @@
3
  Plugin Name: The Events Calendar Shortcode
4
  Plugin URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
5
  Description: An addon to add shortcode functionality for <a href="http://wordpress.org/plugins/the-events-calendar/">The Events Calendar Plugin (Free Version) by Modern Tribe</a>.
6
- Version: 1.2
7
- Author: Event Calendar Newsletter (Brian Hogg)
8
  Author URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
9
  Contributors: Brainchild Media Group, Reddit user miahelf, tallavic, hejeva2
10
- Contributor URL: http://brainchildmediagroup.com, http://www.reddit.com/user/miahelf
11
  License: GPL2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
13
  */
@@ -23,9 +22,12 @@ if ( !defined( 'ABSPATH' ) ) {
23
  * Events calendar shortcode addon main class
24
  *
25
  * @package events-calendar-shortcode
26
- * @author Dandelion Web Design Inc.
27
  * @version 1.0.10
28
  */
 
 
 
29
  class Events_Calendar_Shortcode
30
  {
31
  /**
@@ -33,7 +35,11 @@ class Events_Calendar_Shortcode
33
  *
34
  * @since 1.0.0
35
  */
36
- const VERSION = '1.0.11';
 
 
 
 
37
 
38
  /**
39
  * Constructor. Hooks all interactions to initialize the class.
@@ -43,18 +49,59 @@ class Events_Calendar_Shortcode
43
  *
44
  * @see add_shortcode()
45
  */
46
- public function __construct()
47
- {
48
- add_shortcode('ecs-list-events', array($this, 'ecs_fetch_events') ); // link new function to shortcode name
 
49
  } // END __construct()
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  /**
52
  * Fetch and return required events.
53
  * @param array $atts shortcode attributes
54
  * @return string shortcode output
55
  */
56
- public function ecs_fetch_events( $atts )
57
- {
58
  /**
59
  * Check if events calendar plugin method exists
60
  */
@@ -65,7 +112,7 @@ class Events_Calendar_Shortcode
65
  global $wp_query, $post;
66
  $output = '';
67
 
68
- $atts = shortcode_atts( array(
69
  'cat' => '',
70
  'month' => '',
71
  'limit' => 5,
@@ -82,9 +129,9 @@ class Events_Calendar_Shortcode
82
  'thumb' => 'false',
83
  'thumbwidth' => '',
84
  'thumbheight' => '',
85
- 'contentorder' => 'title, thumbnail, excerpt, date, venue',
86
  'event_tax' => '',
87
- ), $atts, 'ecs-list-events' );
88
 
89
  // Category
90
  if ( $atts['cat'] ) {
@@ -112,7 +159,7 @@ class Events_Calendar_Shortcode
112
 
113
  // Past Event
114
  $meta_date_compare = '>=';
115
- $meta_date_date = date( 'Y-m-d' );
116
 
117
  if ( $atts['time'] == 'past' || !empty( $atts['past'] ) ) {
118
  $meta_date_compare = '<';
@@ -156,86 +203,100 @@ class Events_Calendar_Shortcode
156
  );
157
  }
158
 
159
- $posts = get_posts( array(
160
- 'post_type' => 'tribe_events',
 
161
  'posts_per_page' => $atts['limit'],
162
  'tax_query'=> $atts['event_tax'],
163
  'meta_key' => $atts['key'],
164
  'orderby' => 'meta_value',
165
  'author' => $atts['author'],
166
  'order' => $atts['order'],
167
- 'meta_query' => array( $atts['meta_date'] )
168
- ) );
169
 
170
- if ($posts) {
171
- $output .= '<ul class="ecs-event-list">';
172
  $atts['contentorder'] = explode( ',', $atts['contentorder'] );
173
 
174
- foreach( $posts as $post ) :
175
  setup_postdata( $post );
176
 
177
- $output .= '<li class="ecs-event">';
178
 
179
  // Put Values into $output
180
- foreach ( $atts['contentorder'] as $contentorder ) {
181
  switch ( trim( $contentorder ) ) {
182
- case 'title' :
183
- $output .= '<h4 class="entry-title summary">' .
184
- '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . apply_filters( 'ecs_event_list_title', get_the_title(), $atts ) . '</a>
185
- </h4>';
186
  break;
187
 
188
- case 'thumbnail' :
189
- if( self::isValid($atts['thumb']) ) {
190
  $thumbWidth = is_numeric($atts['thumbwidth']) ? $atts['thumbwidth'] : '';
191
  $thumbHeight = is_numeric($atts['thumbheight']) ? $atts['thumbheight'] : '';
192
- if( !empty($thumbWidth) && !empty($thumbHeight) ) {
193
- $output .= get_the_post_thumbnail(get_the_ID(), array($thumbWidth, $thumbHeight) );
194
  } else {
195
-
196
- $size = ( !empty($thumbWidth) && !empty($thumbHeight) ) ? array( $thumbWidth, $thumbHeight ) : 'medium';
197
-
198
- if ( $thumb = get_the_post_thumbnail( get_the_ID(), $size ) ) {
199
- $output .= '<a href="' . tribe_get_event_link() . '">';
200
- $output .= $thumb;
201
- $output .= '</a>';
202
  }
203
  }
204
  }
205
  break;
206
 
207
- case 'excerpt' :
208
- if( self::isValid($atts['excerpt']) ) {
209
  $excerptLength = is_numeric($atts['excerpt']) ? $atts['excerpt'] : 100;
210
- $output .= '<p class="ecs-excerpt">' .
211
- self::get_excerpt($excerptLength) .
212
- '</p>';
213
  }
214
  break;
215
 
216
- case 'date' :
217
- if( self::isValid($atts['eventdetails']) ) {
218
- $output .= '<span class="duration time">' . apply_filters( 'ecs_event_list_details', tribe_events_event_schedule_details(), $atts ) . '</span>';
 
 
219
  }
220
  break;
221
 
222
- case 'venue' :
223
- if( self::isValid($atts['venue']) ) {
224
- $output .= '<span class="duration venue"><em> at </em>' . apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts ) . '</span>';
 
 
 
 
 
 
 
 
 
 
225
  }
226
  break;
 
 
227
  }
228
  }
229
- $output .= '</li>';
230
- endforeach;
231
- $output .= '</ul>';
232
 
233
- if( self::isValid($atts['viewall']) ) {
234
- $output .= '<span class="ecs-all-events"><a href="' . apply_filters( 'ecs_event_list_viewall_link', tribe_get_events_link(), $atts ) .'" rel="bookmark">' . translate( 'View All Events', 'tribe-events-calendar' ) . '</a></span>';
 
 
235
  }
236
 
237
  } else { //No Events were Found
238
- $output .= translate( $atts['message'], 'tribe-events-calendar' );
239
  } // endif
240
 
241
  wp_reset_query();
@@ -251,9 +312,9 @@ class Events_Calendar_Shortcode
251
  * @param string $prop
252
  * @return boolean
253
  */
254
- private function isValid( $prop )
255
  {
256
- return ($prop !== 'false');
257
  }
258
 
259
  /**
@@ -271,16 +332,20 @@ class Events_Calendar_Shortcode
271
  $excerpt = get_the_content();
272
  }
273
 
274
- $excerpt = preg_replace(" (\[.*?\])", '', $excerpt);
275
  $excerpt = strip_tags( strip_shortcodes($excerpt) );
276
- $excerpt = substr($excerpt, 0, $limit);
277
- $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
278
- $excerpt .= '...';
 
 
279
 
280
  return $excerpt;
281
  }
282
  }
283
 
 
 
284
  /**
285
  * Instantiate the main class
286
  *
3
  Plugin Name: The Events Calendar Shortcode
4
  Plugin URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
5
  Description: An addon to add shortcode functionality for <a href="http://wordpress.org/plugins/the-events-calendar/">The Events Calendar Plugin (Free Version) by Modern Tribe</a>.
6
+ Version: 1.3
7
+ Author: Event Calendar Newsletter
8
  Author URI: https://eventcalendarnewsletter.com/the-events-calendar-shortcode/
9
  Contributors: Brainchild Media Group, Reddit user miahelf, tallavic, hejeva2
 
10
  License: GPL2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  */
22
  * Events calendar shortcode addon main class
23
  *
24
  * @package events-calendar-shortcode
25
+ * @author Brian Hogg
26
  * @version 1.0.10
27
  */
28
+
29
+ if ( ! class_exists( 'Events_Calendar_Shortcode' ) ) {
30
+
31
  class Events_Calendar_Shortcode
32
  {
33
  /**
35
  *
36
  * @since 1.0.0
37
  */
38
+ const VERSION = '1.3';
39
+
40
+ private $admin_page = null;
41
+
42
+ const MENU_SLUG = 'ecs-admin';
43
 
44
  /**
45
  * Constructor. Hooks all interactions to initialize the class.
49
  *
50
  * @see add_shortcode()
51
  */
52
+ public function __construct() {
53
+ add_action( 'admin_menu', array( $this, 'add_menu_page' ), 1000 );
54
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_action_links' ) );
55
+ add_shortcode( 'ecs-list-events', array( $this, 'ecs_fetch_events' ) );
56
  } // END __construct()
57
 
58
+ public function add_menu_page() {
59
+ if ( ! class_exists( 'Tribe__Settings' ) or ! method_exists( Tribe__Settings::instance(), 'should_setup_pages' ) or ! Tribe__Settings::instance()->should_setup_pages() ) {
60
+ return;
61
+ }
62
+
63
+ $page_title = esc_html__( 'Shortcode', 'ecs' );
64
+ $menu_title = esc_html__( 'Shortcode', 'tribe-common' );
65
+ $capability = apply_filters( 'ecs_admin_page_capability', 'install_plugins' );
66
+
67
+ $where = Tribe__Settings::instance()->get_parent_slug();
68
+
69
+ $this->admin_page = add_submenu_page( $where, $page_title, $menu_title, $capability, self::MENU_SLUG, array( $this, 'do_menu_page' ) );
70
+
71
+ add_action( 'admin_print_styles-' . $this->admin_page, array( $this, 'enqueue' ) );
72
+ add_action( 'admin_print_styles', array( $this, 'enqueue_submenu_style' ) );
73
+ }
74
+
75
+ public function enqueue() {
76
+ wp_enqueue_style( 'ecs-admin-css', plugins_url( 'static/ecs-admin.css', __FILE__ ), array(), self::VERSION );
77
+ wp_enqueue_script( 'ecs-admin-js', plugins_url( 'static/ecs-admin.js', __FILE__ ), array(), self::VERSION );
78
+ }
79
+
80
+ /**
81
+ * Function to add a small CSS file to add some colour to the Shortcode submenu item
82
+ */
83
+ public function enqueue_submenu_style() {
84
+ wp_enqueue_style( 'ecs-submenu-css', plugins_url( 'static/ecs-submenu.css', __FILE__ ), array(), self::VERSION );
85
+ }
86
+
87
+ public function do_menu_page() {
88
+ include dirname( __FILE__ ) . '/templates/admin-page.php';
89
+ }
90
+
91
+ public function add_action_links( $links ) {
92
+ $mylinks = array(
93
+ '<a href="' . admin_url( 'edit.php?post_type=tribe_events&page=ecs-admin' ) . '">Settings</a>',
94
+ '<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">Upgrade</a>',
95
+ );
96
+ return array_merge( $links, $mylinks );
97
+ }
98
+
99
  /**
100
  * Fetch and return required events.
101
  * @param array $atts shortcode attributes
102
  * @return string shortcode output
103
  */
104
+ public function ecs_fetch_events( $atts ) {
 
105
  /**
106
  * Check if events calendar plugin method exists
107
  */
112
  global $wp_query, $post;
113
  $output = '';
114
 
115
+ $atts = shortcode_atts( apply_filters( 'ecs_shortcode_atts', array(
116
  'cat' => '',
117
  'month' => '',
118
  'limit' => 5,
129
  'thumb' => 'false',
130
  'thumbwidth' => '',
131
  'thumbheight' => '',
132
+ 'contentorder' => apply_filters( 'ecs_default_contentorder', 'title, thumbnail, excerpt, date, venue', $atts ),
133
  'event_tax' => '',
134
+ ), $atts ), $atts, 'ecs-list-events' );
135
 
136
  // Category
137
  if ( $atts['cat'] ) {
159
 
160
  // Past Event
161
  $meta_date_compare = '>=';
162
+ $meta_date_date = current_time( 'Y-m-d H:i:s' );
163
 
164
  if ( $atts['time'] == 'past' || !empty( $atts['past'] ) ) {
165
  $meta_date_compare = '<';
203
  );
204
  }
205
 
206
+ $posts = tribe_get_events( apply_filters( 'ecs_get_events_args', array(
207
+ 'post_status' => 'publish',
208
+ 'hide_upcoming' => true,
209
  'posts_per_page' => $atts['limit'],
210
  'tax_query'=> $atts['event_tax'],
211
  'meta_key' => $atts['key'],
212
  'orderby' => 'meta_value',
213
  'author' => $atts['author'],
214
  'order' => $atts['order'],
215
+ 'meta_query' => array( $atts['meta_date'] ),
216
+ ), $atts ) );
217
 
218
+ if ( $posts ) {
219
+ $output .= apply_filters( 'ecs_start_tag', '<ul class="ecs-event-list">', $atts );
220
  $atts['contentorder'] = explode( ',', $atts['contentorder'] );
221
 
222
+ foreach( $posts as $post ) {
223
  setup_postdata( $post );
224
 
225
+ $output .= apply_filters( 'ecs_event_start_tag', '<li class="ecs-event">', $atts, $post );
226
 
227
  // Put Values into $output
228
+ foreach ( apply_filters( 'ecs_event_contentorder', $atts['contentorder'], $atts, $post ) as $contentorder ) {
229
  switch ( trim( $contentorder ) ) {
230
+ case 'title':
231
+ $output .= apply_filters( 'ecs_event_title_tag_start', '<h4 class="entry-title summary">', $atts, $post ) .
232
+ '<a href="' . tribe_get_event_link() . '" rel="bookmark">' . apply_filters( 'ecs_event_list_title', get_the_title(), $atts, $post ) . '</a>' .
233
+ apply_filters( 'ecs_event_title_tag_end', '</h4>', $atts, $post );
234
  break;
235
 
236
+ case 'thumbnail':
237
+ if ( self::isValid( $atts['thumb'] ) ) {
238
  $thumbWidth = is_numeric($atts['thumbwidth']) ? $atts['thumbwidth'] : '';
239
  $thumbHeight = is_numeric($atts['thumbheight']) ? $atts['thumbheight'] : '';
240
+ if( !empty( $thumbWidth ) && !empty( $thumbHeight ) ) {
241
+ $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 );
242
  } else {
243
+ if ( $thumb = get_the_post_thumbnail( get_the_ID(), apply_filters( 'ecs_event_thumbnail_size', 'medium', $atts, $post ) ) ) {
244
+ $output .= apply_filters( 'ecs_event_thumbnail_link_start', '<a href="' . tribe_get_event_link() . '">', $atts, $post );
245
+ $output .= apply_filters( 'ecs_event_thumbnail', $thumb, $atts, $post );
246
+ $output .= apply_filters( 'ecs_event_thumbnail_link_end', '</a>', $atts, $post );
 
 
 
247
  }
248
  }
249
  }
250
  break;
251
 
252
+ case 'excerpt':
253
+ if ( self::isValid( $atts['excerpt'] ) ) {
254
  $excerptLength = is_numeric($atts['excerpt']) ? $atts['excerpt'] : 100;
255
+ $output .= apply_filters( 'ecs_event_excerpt_tag_start', '<p class="ecs-excerpt">', $atts, $post ) .
256
+ apply_filters( 'ecs_event_excerpt', self::get_excerpt( $excerptLength ), $atts, $post ) .
257
+ apply_filters( 'ecs_event_excerpt_tag_end', '</p>', $atts, $post );
258
  }
259
  break;
260
 
261
+ case 'date':
262
+ if ( self::isValid( $atts['eventdetails'] ) ) {
263
+ $output .= apply_filters( 'ecs_event_date_tag_start', '<span class="duration time">', $atts, $post ) .
264
+ apply_filters( 'ecs_event_list_details', tribe_events_event_schedule_details(), $atts, $post ) .
265
+ apply_filters( 'ecs_event_date_tag_end', '</span>', $atts, $post );
266
  }
267
  break;
268
 
269
+ case 'venue':
270
+ if ( self::isValid( $atts['venue'] ) ) {
271
+ $output .= apply_filters( 'ecs_event_venue_tag_start', '<span class="duration venue">', $atts, $post ) .
272
+ apply_filters( 'ecs_event_venue_at_tag_start', '<em> ', $atts, $post ) .
273
+ apply_filters( 'ecs_event_venue_at_text', __( 'at', 'the-events-calendar-shortcode' ), $atts, $post ) .
274
+ apply_filters( 'ecs_event_venue_at_tag_end', ' </em>', $atts, $post ) .
275
+ apply_filters( 'ecs_event_list_venue', tribe_get_venue(), $atts, $post ) .
276
+ apply_filters( 'ecs_event_venue_tag_end', '</span>', $atts, $post );
277
+ }
278
+ break;
279
+ case 'date_thumb':
280
+ if ( self::isValid( $atts['eventdetails'] ) ) {
281
+ $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 );
282
  }
283
  break;
284
+ default:
285
+ $output .= apply_filters( 'ecs_event_list_output_custom', '', trim( $contentorder ), $atts, $post );
286
  }
287
  }
288
+ $output .= apply_filters( 'ecs_event_end_tag', '</li>', $atts, $post );
289
+ }
290
+ $output .= apply_filters( 'ecs_end_tag', '</ul>', $atts );
291
 
292
+ if( self::isValid( $atts['viewall'] ) ) {
293
+ $output .= apply_filters( 'ecs_view_all_events_tag_start', '<span class="ecs-all-events">', $atts ) .
294
+ '<a href="' . apply_filters( 'ecs_event_list_viewall_link', tribe_get_events_link(), $atts ) .'" rel="bookmark">' . translate( 'View All Events', 'tribe-events-calendar' ) . '</a>';
295
+ $output .= apply_filters( 'ecs_view_all_events_tag_end', '</span>' );
296
  }
297
 
298
  } else { //No Events were Found
299
+ $output .= apply_filters( 'ecs_no_events_found_message', translate( $atts['message'], 'tribe-events-calendar' ), $atts );
300
  } // endif
301
 
302
  wp_reset_query();
312
  * @param string $prop
313
  * @return boolean
314
  */
315
+ public static function isValid( $prop )
316
  {
317
+ return ( $prop !== 'false' );
318
  }
319
 
320
  /**
332
  $excerpt = get_the_content();
333
  }
334
 
335
+ $excerpt = preg_replace( " (\[.*?\])", '', $excerpt );
336
  $excerpt = strip_tags( strip_shortcodes($excerpt) );
337
+ $excerpt = trim( preg_replace( '/\s+/', ' ', $excerpt ) );
338
+ if ( strlen( $excerpt ) > $limit ) {
339
+ $excerpt = substr( $excerpt, 0, $limit );
340
+ $excerpt .= '...';
341
+ }
342
 
343
  return $excerpt;
344
  }
345
  }
346
 
347
+ }
348
+
349
  /**
350
  * Instantiate the main class
351
  *