1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364:
<?php
namespace EventPost;
class Shortcodes{
public $EP;
function __construct() {
add_action('init', array(&$this,'init'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_list'), array(&$this, 'shortcode_list'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_timeline'), array(&$this, 'shortcode_timeline'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_map'), array(&$this, 'shortcode_map'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'events_cal'), array(&$this, 'shortcode_cal'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_details'), array(&$this, 'shortcode_single'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_term'), array(&$this, 'shortcode_term'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_cat'), array(&$this, 'shortcode_cat'));
add_shortcode(apply_filters('eventpost_shortcode_slug', 'event_search'), array(&$this, 'shortcode_search'));
}
public function init(){
global $EventPost;
$this->EP = $EventPost;
}
public function shortcode_single($atts){
$default_atts = array(
'attribute' => '',
);
$atts = shortcode_atts($default_atts, $atts);
$attribute = sanitize_text_field($atts['attribute']);
$event = $this->EP->retreive();
switch($attribute){
case 'start':
return esc_html($this->EP->human_date($event->time_start));
case 'end':
return esc_html($this->EP->human_date($event->time_end));
case 'address':
return esc_html($event->address);
case 'location':
return esc_html($this->EP->get_singleloc($event, '', 'single'));
case 'date':
return esc_html($this->EP->get_singledate($event, '', 'single'));
default:
return esc_html($this->EP->get_single($event, '', 'single'));
}
}
public function shortcode_term($atts){
$defaults = array(
'tax' => null,
'term' => null,
'post_type' => null,
);
$atts = shortcode_atts(apply_filters('eventpost_params', $defaults, 'shortcode_term'), $atts);
$atts = array(
'tax' => sanitize_text_field($atts['tax']),
'term' => sanitize_text_field($atts['term']),
'post_type' => sanitize_text_field($atts['post_type']),
);
extract($atts);
if(false !== $the_term = $this->EP->retreive_term($term, $tax, $post_type)){
return $this->EP->delta_date($the_term->time_start, $the_term->time_end);
}
}
public function shortcode_cat($_atts){
$atts = shortcode_atts(array(
'cat' => null,
), $_atts);
$atts['tax']='category';
$atts['post_type']='post';
$atts['term']=$atts['cat'];
unset($atts['cat']);
return $this->shortcode_term($atts);
}
public function shortcode_list($_atts) {
$atts = shortcode_atts(apply_filters('eventpost_params', array(
'nb' => 0,
'future' => true,
'past' => false,
'geo' => 0,
'cat' => '',
'tag' => '',
'tax_name' => '',
'tax_term' => '',
'orderby' => 'meta_value',
'order' => 'ASC',
'title' => '',
'type' => 'div',
'before_title' => '<h3>',
'after_title' => '</h3>',
'thumbnail' => '',
'thumbnail_size' => '',
'excerpt' => '',
'width' => '',
'height' => 'auto',
'style' => '',
'pages' => false,
'container_schema' => $this->EP->list_shema['container'],
'item_schema' => $this->EP->list_shema['item'],
'className' => '',
), 'shortcode_list'), $_atts);
if ($atts['container_schema'] != $this->EP->list_shema['container'])
$atts['container_schema'] = html_entity_decode($atts['container_schema']);
if ($atts['item_schema'] != $this->EP->list_shema['item'])
$atts['item_schema'] = html_entity_decode($atts['item_schema']);
return $this->EP->list_events($atts, 'event_list', 'shortcode');
}
public function shortcode_timeline($_atts) {
$atts = shortcode_atts(apply_filters('eventpost_params', array(
'nb' => 0,
'future' => true,
'past' => false,
'geo' => 0,
'cat' => '',
'tag' => '',
'tax_name' => '',
'tax_term' => '',
'title' => '',
'type' => 'div',
'before_title' => '<h3>',
'after_title' => '</h3>',
'excerpt' => '',
'width' => '',
'height' => 'auto',
'style' => '',
'container_schema' => $this->EP->timeline_shema['container'],
'item_schema' => $this->EP->timeline_shema['item'],
'className' => '',
), 'shortcode_list'), $_atts);
if ($atts['container_schema'] != $this->EP->timeline_shema['container'])
$atts['container_schema'] = html_entity_decode($atts['container_schema']);
if ($atts['item_schema'] != $this->EP->timeline_shema['item'])
$atts['item_schema'] = html_entity_decode($atts['item_schema']);
return $this->EP->list_events($atts, 'event_timeline', 'shortcode');
}
public function shortcode_map($_atts) {
$ep_settings = $this->EP->settings;
$defaults = array(
'width' => '',
'height' => '',
'tile' => $ep_settings['tile'],
'pop_element_schema' => '',
'htmlPop_element_schema' => '',
'title' => '',
'before_title' => '<h3>',
'after_title' => '</h3>',
'style' => '',
'thumbnail' => '',
'thumbnail_size' => '',
'excerpt' => '',
'zoom' => '',
'map_position' => '',
'latitude' => '',
'longitude' => '',
'list' => '0',
'nb' => 0,
'future' => true,
'past' => false,
'cat' => '',
'tag' => '',
'tax_name' => '',
'tax_term' => '',
'orderby' => 'meta_value',
'order' => 'ASC',
'className' => '',
);
foreach($this->EP->map_interactions as $int_key=>$int_name){
$defaults[$int_key]=true;
}
foreach($this->EP->map_interactions as $int_key=>$int_name){
$defaults['disable_'.strtolower($int_key)]=false;
}
$atts = shortcode_atts(apply_filters('eventpost_params', $defaults, 'shortcode_map'), $_atts);
foreach($this->EP->map_interactions as $int_key=>$int_name){
if($atts['disable_'.strtolower($int_key)]==true){
$atts[$int_key]=false;
}
unset($atts['disable_'.strtolower($int_key)]);
}
$atts['geo'] = 1;
$atts['type'] = 'div';
return $this->EP->list_events($atts, 'event_geolist', 'shortcode');
}
public function shortcode_cal($_atts) {
$defaults = array(
'date' => date('Y-n'),
'cat' => '',
'mondayfirst' => 0,
'display_title' => 0,
'datepicker' => 1,
'tax_name' => '',
'tax_term' => '',
'thumbnail' => '',
'className' => '',
);
$atts = shortcode_atts(apply_filters('eventpost_params', $defaults, 'shortcode_cal'), $_atts);
$atts = array(
'date' => sanitize_text_field($atts['date']),
'cat' => sanitize_text_field($atts['cat']),
'mondayfirst' => intval($atts['mondayfirst']),
'display_title' => intval($atts['display_title']),
'datepicker' => intval($atts['datepicker']),
'tax_name' => sanitize_text_field($atts['tax_name']),
'tax_term' => sanitize_text_field($atts['tax_term']),
'thumbnail' => sanitize_text_field($atts['thumbnail']),
'className' => esc_attr($atts['className']),
);
extract($atts);
if (preg_match('/[^a-zA-Z0-9\-\+ ]/', $date)) {
$date = date('Y-n');
}
return '<div
class="eventpost_calendar ' . esc_attr($className) . '"
data-tax_name="' . esc_attr($tax_name) . '"
data-tax_term="' . esc_attr($tax_term) . '"
data-cat="' . esc_attr($cat) . '"
data-date="' . esc_attr($date) . '"
data-mf="' . esc_attr($mondayfirst) . '"
data-dp="' . esc_attr($datepicker) . '"
data-title="'. esc_attr($display_title) .'"
>'
. wp_kses_post($this->EP->calendar($atts))
. '</div>';
}
public function shortcode_search($_atts){
return $this->EP->search($_atts);
}
}