PluginProbe
Event Post / 5.0
Event Post v5.0
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
← All changes | inc/shortcodes.php +249 -96 trunk5.0 View file →
@@ -1,9 +1,8 @@
1 1 <?php
2 +
2 3 /**
3 4 * Implements all shortcodes features
4 - *
5 - * @package event-post
6 5 */
7 6 class EventPost_Shortcodes{
8 7 public $EP;
9 8
@@ -8,17 +7,19 @@
8 7 public $EP;
9 8
10 9 function __construct() {
11 10 //Shortcodes
12 - add_action('init', array(&$this,'init'));
13 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_list'), array(&$this, 'shortcode_list'));
14 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_timeline'), array(&$this, 'shortcode_timeline'));
15 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_map'), array(&$this, 'shortcode_map'));
16 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_cal'), array(&$this, 'shortcode_cal'));
17 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_details'), array(&$this, 'shortcode_single'));
18 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_term'), array(&$this, 'shortcode_term'));
19 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_cat'), array(&$this, 'shortcode_cat'));
20 - add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_search'), array(&$this, 'shortcode_search'));
11 + add_action('init', array(&$this,'init'));
12 + add_shortcode('events_list', array(&$this, 'shortcode_list'));
13 + add_shortcode('events_map', array(&$this, 'shortcode_map'));
14 + add_shortcode('events_cal', array(&$this, 'shortcode_cal'));
15 + add_shortcode('event_details', array(&$this, 'shortcode_single'));
16 + add_shortcode('event_term', array(&$this, 'shortcode_term'));
17 + add_shortcode('event_cat', array(&$this, 'shortcode_cat'));
18 + add_shortcode('event_search', array(&$this, 'shortcode_search'));
19 + // Workaround for ACF select2 bug
20 + // see: https://github.com/wp-shortcake/shortcake/issues/660
21 + add_filter( 'acf/settings/select2_version', array(&$this, 'return4'));
21 22 }
22 23
23 24 /**
24 25 * Call functions when WP is ready
@@ -25,10 +26,15 @@
25 26 */
26 27 public function init(){
27 28 global $EventPost;
28 29 $this->EP = $EventPost;
30 + $this->shortcode_ui();
29 31 }
30 32
33 + public function return4(){
34 + return 4;
35 + }
36 +
31 37 /**
32 38 * shortcode_single
33 39 * @param array $atts
34 40 * @filter : eventpost_params
@@ -90,9 +96,9 @@
90 96 - **future=1** *(boolean, retreive, or not, events in the future, default = 1)*
91 97 - **past=0** *(boolean, retreive, or not, events in the past, default = 0)*
92 98 - **cat=''** *(string, select posts only from the selected category, default=null, for all categories)*
93 99 - **tag=''** *(string, select posts only from the selected tag, default=null, for all tags)*
94 - - **geo=0** *(boolean, retreives or not, only events which have geolocation informations, default=0)*
100 + - **geo=0** *(boolean, retreives or not, only events wich have geolocation informations, default=0)*
95 101 - **order="ASC"** *(string (can be "ASC" or "DESC")*
96 102 - **orderby="meta_value"** *(string (if set to "meta_value" events are sorted by event date, possible values are native posts fileds : "post_title","post_date" etc...)*
97 103
98 104 ### Display parameters
@@ -115,20 +121,18 @@
115 121 public function shortcode_list($_atts) {
116 122 $atts = shortcode_atts(apply_filters('eventpost_params', array(
117 123 // Filters
118 124 'nb' => 0,
125 + 'type' => 'div',
119 126 'future' => true,
120 127 'past' => false,
121 128 'geo' => 0,
122 129 'cat' => '',
123 130 'tag' => '',
124 - 'tax_name' => '',
125 - 'tax_term' => '',
126 131 'orderby' => 'meta_value',
127 132 'order' => 'ASC',
128 133 'title' => '',
129 134 // Display
130 - 'type' => 'div',
131 135 'before_title' => '<h3>',
132 136 'after_title' => '</h3>',
133 137 'thumbnail' => '',
134 138 'thumbnail_size' => '',
@@ -135,13 +139,11 @@
135 139 'excerpt' => '',
136 140 'width' => '',
137 141 'height' => 'auto',
138 142 'style' => '',
139 - 'pages' => false,
140 143 'container_schema' => $this->EP->list_shema['container'],
141 144 'item_schema' => $this->EP->list_shema['item'],
142 - 'className' => '',
143 - ), 'shortcode_list'), $_atts);
145 + ), 'shortcode_list'), $_atts);
144 146
145 147 if ($atts['container_schema'] != $this->EP->list_shema['container'])
146 148 $atts['container_schema'] = html_entity_decode($atts['container_schema']);
147 149 if ($atts['item_schema'] != $this->EP->list_shema['item'])
@@ -149,67 +151,8 @@
149 151 return $this->EP->list_events($atts, 'event_list', 'shortcode');
150 152 }
151 153
152 154 /**
153 - * Shortcode to display a list of events
154 - *
155 - ### Query parameters
156 -
157 - - **nb=5** *(number of post, -1 is all, default: 5)*
158 - - **future=1** *(boolean, retreive, or not, events in the future, default = 1)*
159 - - **past=0** *(boolean, retreive, or not, events in the past, default = 0)*
160 - - **cat=''** *(string, select posts only from the selected category, default=null, for all categories)*
161 - - **tag=''** *(string, select posts only from the selected tag, default=null, for all tags)*
162 - - **geo=0** *(boolean, retreives or not, only events which have geolocation informations, default=0)*
163 -
164 - ### Display parameters
165 -
166 - - **excerpt=""** * (Bool, default:false, used to display posts excerpts)*
167 - - **style=""** * (String, add some inline CSS to the list wrapper)*
168 - - **type=div** *(string, possible values are : div, ul, ol default=div)*
169 - - **title=''** *(string, hidden if no events is found)*
170 - - **before_title="&lt;h3&gt;"** *(string (default &lt;h3&gt;)*
171 - - **after_title="&lt;/h3&gt;"** *(string (default &lt;/h3&gt;)*
172 - - **container_schema=""** *(string html schema to display list)*
173 - - **item_schema=""** *(string html schema to display item)*
174 - *
175 - * @param array $_atts
176 - * @filter eventpost_params
177 - * @return string
178 - */
179 - public function shortcode_timeline($_atts) {
180 - $atts = shortcode_atts(apply_filters('eventpost_params', array(
181 - // Filters
182 - 'nb' => 0,
183 - 'future' => true,
184 - 'past' => false,
185 - 'geo' => 0,
186 - 'cat' => '',
187 - 'tag' => '',
188 - 'tax_name' => '',
189 - 'tax_term' => '',
190 - 'title' => '',
191 - // Display
192 - 'type' => 'div',
193 - 'before_title' => '<h3>',
194 - 'after_title' => '</h3>',
195 - 'excerpt' => '',
196 - 'width' => '',
197 - 'height' => 'auto',
198 - 'style' => '',
199 - 'container_schema' => $this->EP->timeline_shema['container'],
200 - 'item_schema' => $this->EP->timeline_shema['item'],
201 - 'className' => '',
202 - ), 'shortcode_list'), $_atts);
203 -
204 - if ($atts['container_schema'] != $this->EP->timeline_shema['container'])
205 - $atts['container_schema'] = html_entity_decode($atts['container_schema']);
206 - if ($atts['item_schema'] != $this->EP->timeline_shema['item'])
207 - $atts['item_schema'] = html_entity_decode($atts['item_schema']);
208 - return $this->EP->list_events($atts, 'event_timeline', 'shortcode');
209 - }
210 -
211 - /**
212 155 * Shortcode to display a map of events
213 156 * @param array $_atts
214 157 * @filter eventpost_params
215 158 * @return string
@@ -214,17 +157,15 @@
214 157 * @filter eventpost_params
215 158 * @return string
216 159 */
217 160 public function shortcode_map($_atts) {
218 -
219 161 $ep_settings = $this->EP->settings;
162 +
220 163 $defaults = array(
221 164 // Display
222 165 'width' => '',
223 166 'height' => '',
224 167 'tile' => $ep_settings['tile'],
225 - 'pop_element_schema' => '',
226 - 'htmlPop_element_schema' => '',
227 168 'title' => '',
228 169 'before_title' => '<h3>',
229 170 'after_title' => '</h3>',
230 171 'style' => '',
@@ -230,13 +171,9 @@
230 171 'style' => '',
231 172 'thumbnail' => '',
232 173 'thumbnail_size' => '',
233 174 'excerpt' => '',
234 - 'zoom' => '',
235 - 'map_position' => '',
236 - 'latitude' => '',
237 - 'longitude' => '',
238 - 'list' => '0',
175 + 'zoom'=>'',
239 176 // Filters
240 177 'nb' => 0,
241 178 'future' => true,
242 179 'past' => false,
@@ -241,13 +178,10 @@
241 178 'future' => true,
242 179 'past' => false,
243 180 'cat' => '',
244 181 'tag' => '',
245 - 'tax_name' => '',
246 - 'tax_term' => '',
247 182 'orderby' => 'meta_value',
248 183 'order' => 'ASC',
249 - 'className' => '',
250 184 );
251 185 // UI options
252 186 foreach($this->EP->map_interactions as $int_key=>$int_name){
253 187 $defaults[$int_key]=true;
@@ -281,17 +215,12 @@
281 215 $atts = shortcode_atts(apply_filters('eventpost_params', array(
282 216 'date' => date('Y-n'),
283 217 'cat' => '',
284 218 'mondayfirst' => 0, //1 : weeks starts on monday
285 - 'display_title' => 0,
286 - 'datepicker' => 1,
287 - 'tax_name' => '',
288 - 'tax_term' => '',
289 - 'thumbnail' => '',
290 - 'className' => '',
291 - ), 'shortcode_cal'), $_atts);
219 + 'datepicker' => 1
220 + ), 'shortcode_cal'), $_atts);
292 221 extract($atts);
293 - return '<div class="eventpost_calendar '.$className.'" data-tax_name="' . $tax_name . '" data-tax_term="' . $tax_term . '" data-cat="' . $cat . '" data-date="' . $date . '" data-mf="' . $mondayfirst . '" data-dp="' . $datepicker . '" data-title="'. $display_title .'">' . $this->EP->calendar($atts) . '</div>';
222 + return '<div class="eventpost_calendar" data-cat="' . $cat . '" data-date="' . $date . '" data-mf="' . $mondayfirst . '" data-dp="' . $datepicker . '">' . $this->EP->calendar($atts) . '</div>';
294 223 }
295 224
296 225 /**
297 226 *
@@ -301,5 +230,229 @@
301 230 public function shortcode_search($_atts){
302 231 return $this->EP->search($_atts);
303 232 }
304 233
234 + /**
235 + * set_shortcode_ui
236 + * needs Shortcake (shortcode UI) plugin
237 + * https://wordpress.org/plugins/shortcode-ui/
238 + */
239 + public function shortcode_ui(){
240 + if(!function_exists('shortcode_ui_register_for_shortcode')){
241 + return;
242 + }
243 + $shortcodes_list_atts=array(
244 + 'label' => __('Events list','event-post'),
245 + 'listItemImage' => 'dashicons-calendar',
246 + 'post_type'=>array('page','post'),
247 + 'attrs' => array(
248 + 0=>array(
249 + 'label' => __('Number of posts','event-post'),
250 + 'attr' => 'nb',
251 + 'type' => 'number',
252 + 'description' => __('-1 is for: no limit','event-post')
253 + ),
254 + 1=>array(
255 + 'label' => __('Categories','event-post'),
256 + 'attr' => 'cat',
257 + 'type' => 'term_select',
258 + 'taxonomy' => 'category',
259 + 'multiple' => true,
260 + ),
261 + 2=>array(
262 + 'label' => __('Tags','event-post'),
263 + 'attr' => 'tag',
264 + 'type' => 'term_select',
265 + 'taxonomy' => 'post_tag',
266 + 'multiple' => true,
267 + ),
268 + 3=>array(
269 + 'label' => __('Future events:','event-post'),
270 + 'attr' => 'future',
271 + 'type' => 'select',
272 + 'options' => array(
273 + '1' => __('Yes','event-post'),
274 + '0' => __('No','event-post'),
275 + ),
276 + ),
277 + 4=>array(
278 + 'label' => __('Past events:','event-post'),
279 + 'attr' => 'past',
280 + 'type' => 'select',
281 + 'options' => array(
282 + '1' => __('Yes','event-post'),
283 + '0' => __('No','event-post'),
284 + ),
285 + ),
286 + 5=>array(
287 + 'label' => __('Only geotagged events:','event-post'),
288 + 'attr' => 'geo',
289 + 'type' => 'select',
290 + 'options' => array(
291 + '1' => __('Yes','event-post'),
292 + '0' => __('No','event-post'),
293 + ),
294 + ),
295 + 6=>array(
296 + 'label' => __('Thumbnail:','event-post'),
297 + 'attr' => 'thumbnail',
298 + 'type' => 'select',
299 + 'options' => array(
300 + '1' => __('Yes','event-post'),
301 + '0' => __('No','event-post'),
302 + ),
303 + ),
304 + 7=>array(
305 + 'label' => __('Thumbnail size:','event-post'),
306 + 'attr' => 'thumbnail_size',
307 + 'type' => 'select',
308 + 'options' => array(
309 + 'thumbnail' => __('Thumbnail'),
310 + 'medium' => __('Medium'),
311 + 'large' => __('Large'),
312 + ),
313 + ),
314 + 8=>array(
315 + 'label' => __('Order by:','event-post'),
316 + 'attr' => 'orderby',
317 + 'type' => 'select',
318 + 'options' => array(
319 + 'meta_value' => __('Date'),
320 + 'title' => __('Title'),
321 + ),
322 + ),
323 + 9=>array(
324 + 'label' => __('Order:','event-post'),
325 + 'attr' => 'order',
326 + 'type' => 'select',
327 + 'options' => array(
328 + 'ASC' => __('Asc.'),
329 + 'DESC' => __('Desc.'),
330 + ),
331 + ),
332 + ),
333 + );
334 + /*
335 + * Map
336 + */
337 + $shortcodes_map_atts = $shortcodes_list_atts;
338 + unset($shortcodes_map_atts['attrs'][5]); // Remove geotagged attr
339 + unset($shortcodes_map_atts['attrs'][8]); // Remove orderby attr
340 + unset($shortcodes_map_atts['attrs'][9]); // Remove order attr
341 + array_unshift($shortcodes_map_atts['attrs'],
342 + array(
343 + 'label' => __('Width','event-post'),
344 + 'attr' => 'width',
345 + 'type' => 'text',
346 + ),
347 + array(
348 + 'label' => __('Height','event-post'),
349 + 'attr' => 'height',
350 + 'type' => 'text',
351 + ),
352 + array(
353 + 'label' => __('Zoom','event-post'),
354 + 'attr' => 'zoom',
355 + 'type' => 'number',
356 + )
357 + );
358 + $shortcodes_map_atts['label']=__('Events map','event-post');
359 + $shortcodes_map_atts['listItemImage']='dashicons-location-alt';
360 + foreach($this->EP->map_interactions as $int_key=>$int_name){
361 + $shortcodes_map_atts['attrs'][]=array(
362 + 'label' => sprintf(__('Disable %s interaction','event-post'), $int_name),
363 + 'attr' => 'disable_'.$int_key,
364 + 'type' => 'checkbox'
365 + );
366 + }
367 + shortcode_ui_register_for_shortcode('events_list', apply_filters('eventpost_shortcodeui_list',$shortcodes_list_atts));
368 + shortcode_ui_register_for_shortcode('events_map', apply_filters('eventpost_shortcodeui_map',$shortcodes_map_atts));
369 +
370 + /*
371 + * Calendar
372 + */
373 + $shortcodes_cal_atts=array(
374 + 'label' => __('Events calendar','event-post'),
375 + 'listItemImage' => 'dashicons-calendar-alt',
376 + 'post_type'=>array('page','post'),
377 + 'attrs' => array(
378 + array(
379 + 'label' => __('Default date','event-post'),
380 + 'attr' => 'date',
381 + 'type' => 'text',
382 + 'description' => date('Y-n')
383 + ),
384 + array(
385 + 'label' => __('Categories','event-post'),
386 + 'attr' => 'cat',
387 + 'type' => 'text',
388 + ),
389 + array(
390 + 'label' => __('Monday first','event-post'),
391 + 'attr' => 'mondayfirst',
392 + 'type' => 'checkbox',
393 + ),
394 + array(
395 + 'label' => __('Date selector','event-post'),
396 + 'attr' => 'choose',
397 + 'type' => 'checkbox',
398 + )
399 + )
400 + );
401 + shortcode_ui_register_for_shortcode('events_cal', apply_filters('eventpost_shortcodeui_cal',$shortcodes_cal_atts));
402 + /*
403 + * Details
404 + */
405 + $shortcodes_details_atts=array(
406 + 'label' => __('Event details','event-post'),
407 + 'listItemImage' => 'dashicons-clock',
408 + 'attrs' => array(
409 + array(
410 + 'label' => __('Attribute','event-post'),
411 + 'attr' => 'attribute',
412 + 'type' => 'select',
413 + 'options' => array(
414 + '' => __('Full details','event-post'),
415 + 'date' => __('Full date','event-post'),
416 + 'start' => __('Begin date','event-post'),
417 + 'end' => __('End date','event-post'),
418 + 'address' => __('Address text','event-post'),
419 + 'location' => __('Location','event-post'),
420 + ),
421 + ),
422 + )
423 + );
424 + shortcode_ui_register_for_shortcode('event_details', apply_filters('eventpost_shortcodeui_details',$shortcodes_details_atts));
425 +
426 +
427 + /*
428 + * Search
429 + */
430 + $shortcodes_search_atts=array(
431 + 'label' => __('Events search form','event-post'),
432 + 'listItemImage' => 'dashicons-search',
433 + 'attrs' => array(
434 + array(
435 + 'label' => __('Keywords','event-post'),
436 + 'attr' => 'q',
437 + 'type' => 'select',
438 + 'options' => array(
439 + '1' => __('Yes','event-post'),
440 + '0' => __('No','event-post'),
441 + ),
442 + ),
443 + array(
444 + 'label' => __('Dates','event-post'),
445 + 'attr' => 'dates',
446 + 'type' => 'select',
447 + 'options' => array(
448 + '1' => __('Yes','event-post'),
449 + '0' => __('No','event-post'),
450 + ),
451 +
452 + ),
453 + )
454 + );
455 + shortcode_ui_register_for_shortcode('event_search', apply_filters('eventpost_shortcodeui_search',$shortcodes_search_atts));
456 +
457 + }
305 458 }