Overview

Namespaces

  • EventPost
  • None

Classes

  • EventPost
  • EventPost\Categories
  • EventPost\DashIcons
  • EventPost\Settings
  • EventPost_Cal
  • EventPost_List
  • EventPost_Map
  • EventPost_Search
  • EventPost_Shortcodes
  • EventPostChild
  • EventPostMU
  • EventPostWeather

Functions

  • event_post_format_color
  • event_post_get_all_terms
  • eventdetails_block_init
  • EventPost
  • EventPost\product_event_tab
  • EventPost\woocommerce_product_tabs
  • EventPost\woocommerce_rich_result
  • eventpost_list_block_init
  • eventpost_timeline_block_init
  • eventscalendar_block_init
  • eventsmap_block_init
  • get_the_date_end
  • get_the_date_start
  • get_the_dates
  • get_the_location
  • the_date_end
  • the_date_start
  • the_dates
  • the_location
  • Overview
  • Namespace
  • Class
  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: 
<?php
/**
 * Implements all shortcodes features
 *
 * @package event-post
 */
class EventPost_Shortcodes{
    public $EP;

    function __construct() {
        //Shortcodes
        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'));
    }

    /**
     * Call functions when WP is ready
     */
    public function init(){
        global $EventPost;
        $this->EP = $EventPost;
    }

    /**
     * shortcode_single
     * @param array $atts
     * @filter : eventpost_params
     * @return string
     */
    public function shortcode_single($atts){
    extract(shortcode_atts(apply_filters('eventpost_params', array(
            'attribute' => '',
                        ), 'shortcode_single'), $atts));
    $event = $this->EP->retreive();
    switch($attribute){
        case 'start':
        return $this->EP->human_date($event->time_start);
        case 'end':
        return $this->EP->human_date($event->time_end);
        case 'address':
        return $event->address;
        case 'location':
        return $this->EP->get_singleloc($event, '', 'single');
        case 'date':
        return $this->EP->get_singledate($event, '', 'single');
        default:
        return $this->EP->get_single($event, '', 'single');
    }
    }

    /**
     *
     * @param array $atts
     * @return string
     */
    public function shortcode_term($atts){
        extract(shortcode_atts(apply_filters('eventpost_params', array(
            'tax' => null,
            'term' => null,
            'post_type' => null,
                        ), 'shortcode_term'), $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);
    }

    /**
     * Shortcode to display a list of events
     *
        ### Query parameters

        - **nb=5** *(number of post, -1 is all, default: 5)*
        - **future=1** *(boolean, retreive, or not, events in the future, default = 1)*
        - **past=0** *(boolean, retreive, or not, events in the past, default = 0)*
        - **cat=''** *(string, select posts only from the selected category, default=null, for all categories)*
        - **tag=''** *(string, select posts only from the selected tag, default=null, for all tags)*
        - **geo=0** *(boolean, retreives or not, only events which have geolocation informations, default=0)*
        - **order="ASC"** *(string (can be "ASC" or "DESC")*
        - **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...)*

        ### Display parameters

        - **thumbnail=""** * (Bool, default:false, used to display posts thumbnails)*
        - **thumbnail_size=""** * (String, default:"thmbnail", can be set to any existing size : "medium","large","full" etc...)*
        - **excerpt=""** * (Bool, default:false, used to display posts excerpts)*
        - **style=""** * (String, add some inline CSS to the list wrapper)*
        - **type=div** *(string, possible values are : div, ul, ol default=div)*
        - **title=''** *(string, hidden if no events is found)*
        - **before_title="&lt;h3&gt;"** *(string (default &lt;h3&gt;)*
        - **after_title="&lt;/h3&gt;"** *(string (default &lt;/h3&gt;)*
        - **container_schema=""** *(string html schema to display list)*
        - **item_schema=""** *(string html schema to display item)*
     *
     * @param array $_atts
     * @filter eventpost_params
     * @return string
     */
    public function shortcode_list($_atts) {
        $atts = shortcode_atts(apply_filters('eventpost_params', array(
            // Filters
            'nb' => 0,
            'future' => true,
            'past' => false,
            'geo' => 0,
            'cat' => '',
            'tag' => '',
            'tax_name' => '',
            'tax_term' => '',
            'orderby' => 'meta_value',
            'order' => 'ASC',
            'title' => '',
            // Display
            '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');
    }

    /**
     * Shortcode to display a list of events
     *
        ### Query parameters

        - **nb=5** *(number of post, -1 is all, default: 5)*
        - **future=1** *(boolean, retreive, or not, events in the future, default = 1)*
        - **past=0** *(boolean, retreive, or not, events in the past, default = 0)*
        - **cat=''** *(string, select posts only from the selected category, default=null, for all categories)*
        - **tag=''** *(string, select posts only from the selected tag, default=null, for all tags)*
        - **geo=0** *(boolean, retreives or not, only events which have geolocation informations, default=0)*

        ### Display parameters

        - **excerpt=""** * (Bool, default:false, used to display posts excerpts)*
        - **style=""** * (String, add some inline CSS to the list wrapper)*
        - **type=div** *(string, possible values are : div, ul, ol default=div)*
        - **title=''** *(string, hidden if no events is found)*
        - **before_title="&lt;h3&gt;"** *(string (default &lt;h3&gt;)*
        - **after_title="&lt;/h3&gt;"** *(string (default &lt;/h3&gt;)*
        - **container_schema=""** *(string html schema to display list)*
        - **item_schema=""** *(string html schema to display item)*
     *
     * @param array $_atts
     * @filter eventpost_params
     * @return string
     */
    public function shortcode_timeline($_atts) {
        $atts = shortcode_atts(apply_filters('eventpost_params', array(
            // Filters
            'nb' => 0,
            'future' => true,
            'past' => false,
            'geo' => 0,
            'cat' => '',
            'tag' => '',
            'tax_name' => '',
            'tax_term' => '',
            'title' => '',
            // Display
            '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');
    }

    /**
     * Shortcode to display a map of events
     * @param array $_atts
     * @filter eventpost_params
     * @return string
     */
    public function shortcode_map($_atts) {
      
        $ep_settings = $this->EP->settings;
        $defaults = array(
            // Display
            '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',
            // Filters
            'nb' => 0,
            'future' => true,
            'past' => false,
            'cat' => '',
            'tag' => '',
            'tax_name' => '',
            'tax_term' => '',
            'orderby' => 'meta_value',
            'order' => 'ASC',
            'className' => '',
        );
            // UI options
        foreach($this->EP->map_interactions as $int_key=>$int_name){
            $defaults[$int_key]=true;
        }
            // - UI options
        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);
            // UI options
        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'); //$nb,'div',$future,$past,1,'event_geolist');
    }

    /**
     * Shortcode to display a calendar of events
     * @param array $_atts
     * @filter eventpost_params
     * @return string
     */
    public function shortcode_cal($_atts) {
    $this->EP->load_scripts();
        $atts = shortcode_atts(apply_filters('eventpost_params', array(
            'date' => date('Y-n'),
            'cat' => '',
            'mondayfirst' => 0, //1 : weeks starts on monday
            'display_title' => 0,
            'datepicker' => 1,
            'tax_name' => '',
            'tax_term' => '',
            'thumbnail' => '',
            'className' => '',
        ), 'shortcode_cal'), $_atts);
        extract($atts);
        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>';
    }

    /**
     *
     * @param type $_atts
     * @return type
     */
    public function shortcode_search($_atts){
        return $this->EP->search($_atts);
    }

}
API documentation generated by ApiGen