/** * Load a template part into a template * * Identical to {@see `get_template_part()`} except that it uses {@see `eo_locate_template()`} * instead of {@see `locate_template()`}. * * Makes it easy for a theme to reuse sections of code in a easy to overload way * for child themes. Looks for and includes templates {$slug}-{$name}.php * * You may include the same template part multiple times. * * @uses eo_locate_template() * @since 1.7 * @uses do_action() Calls `get_template_part_{$slug}` action. * * @param string $slug The slug name for the generic template. * @param string $name The name of the specialised template. */ function eo_get_template_part($slug, $name = null) { do_action("get_template_part_{$slug}", $slug, $name); $templates = array(); if (isset($name)) { $templates[] = "{$slug}-{$name}.php"; } $templates[] = "{$slug}.php"; eo_locate_template($templates, true, false); }
function eventorganiser_posterboard_shortcode_handler($atts = array()) { $defaults = array('filters' => ''); $query = array_diff_key((array) $atts, $defaults); $atts = shortcode_atts($defaults, $atts); $query = array_merge(array('posts_per_page' => 10), $query); //Get template ob_start(); eo_locate_template('single-event-board-item.html', true, false); $template = ob_get_contents(); ob_end_clean(); //Load & 'localize' script if (!eventorganiser_get_option('disable_css')) { wp_enqueue_style('eo_posterboard'); } wp_enqueue_script('eo_posterboard'); wp_localize_script('eo_posterboard', 'eventorganiser_posterboard', array('url' => admin_url('admin-ajax.php'), 'loading' => __('Loading...', 'event-organiser-posterboard'), 'load_more' => __('Load more', 'event-organiser-posterboard'), 'template' => $template, 'query' => $query)); //Handle filters $filters = explode(',', $atts['filters']); $filers_markup = ''; $venues = eo_get_venues(); $cats = get_terms(array('event-category'), array('hide_empty' => false)); //'state'/'country'/'city' functions only available in Pro $is_pro_active = in_array('event-organiser-pro/event-organiser-pro.php', (array) get_option('active_plugins', array())); if ($filters) { foreach ($filters as $filter) { $filter = strtolower(trim($filter)); switch ($filter) { case 'venue': if ($venues) { foreach ($venues as $venue) { $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-venue eo-eb-filter-venue-%1$d" data-filter-type="venue" data-venue="%1$d" data-filter-on="false">%2$s</a>', $venue->term_id, $venue->name); } } break; case 'category': if ($cats) { foreach ($cats as $cat) { $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>', $cat->term_id, $cat->name); } } $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-category eo-eb-filter-category-%1$d" data-filter-type="category" data-category="%1$d" data-filter-on="false">%2$s</a>', 0, __('Uncategorised', 'event-organiser-posterboard')); break; case 'city': case 'state': case 'country': //If Pro isn't active, this won't work if (!$is_pro_active) { break; } if ('city' == $filter) { $terms = eo_get_venue_cities(); } elseif ('state' == $filter) { $terms = eo_get_venue_states(); } else { $terms = eo_get_venue_countries(); } if ($terms) { foreach ($terms as $term) { $filers_markup .= sprintf('<a href="#" class="eo-eb-filter eo-eb-filter-%1$s eo-eb-filter-%1$s-%2$s" data-filter-type="%1$s" data-%1$s="%2$s" data-filter-on="false">%2$s</a>', $filter, $term); } } break; } } } return '<div id="event-board">' . '<div id="event-board-filters" data-filters="">' . $filers_markup . '</div>' . '<div id="event-board-items"></div>' . '<div id="event-board-more"></div>' . '</div>'; }
function eventorganiser_list_events($query, $args = array(), $echo = 1) { $args = array_merge(array('id' => '', 'class' => 'eo-event-list', 'type' => 'shortcode', 'no_events' => ''), $args); /* Pass these defaults - backwards compat with using eo_get_events()*/ $query = wp_parse_args($query, array('posts_per_page' => -1, 'post_type' => 'event', 'suppress_filters' => false, 'orderby' => 'eventstart', 'order' => 'ASC', 'showrepeats' => 1, 'group_events_by' => '', 'showpastevents' => true)); //Make sure false and 'False' etc actually get parsed as 0/false (input from shortcodes, for instance, can be varied). //This maybe moved to the shortcode handler if this function is made public. if (strtolower($query['showpastevents']) === 'false') { $query['showpastevents'] = 0; } if (!empty($query['numberposts'])) { $query['posts_per_page'] = (int) $query['numberposts']; } $template = isset($args['template']) ? $args['template'] : ''; global $eo_event_loop, $eo_event_loop_args; $eo_event_loop_args = $args; $eo_event_loop = new WP_Query($query); /** * @ignore * Try to find template - backwards compat. Don't use this filter. Will be removed! */ $template_file = apply_filters('eventorganiser_event_list_loop', false); $template_file = locate_template($template_file); if ($template_file || empty($template)) { ob_start(); if (empty($template_file)) { $template_file = eo_locate_template(array($eo_event_loop_args['type'] . '-event-list.php', 'event-list.php'), true, false); } else { require $template_file; } $html = ob_get_contents(); ob_end_clean(); } else { //Using the 'placeholder' template $no_events = isset($args['no_events']) ? $args['no_events'] : ''; $line_wrap = '<li class="%2$s">%1$s</li>'; $id = !empty($args['id']) ? 'id="' . esc_attr($args['id']) . '"' : ''; $container = '<ul ' . $id . ' class="%2$s">%1$s</ul>'; $html = ''; if ($eo_event_loop->have_posts()) { while ($eo_event_loop->have_posts()) { $eo_event_loop->the_post(); $event_classes = eo_get_event_classes(); $html .= sprintf($line_wrap, EventOrganiser_Shortcodes::read_template($template), esc_attr(implode(' ', $event_classes))); } } elseif ($no_events) { $html .= sprintf($line_wrap, $no_events, 'eo-no-events'); } $html = sprintf($container, $html, esc_attr($args['class'])); } wp_reset_postdata(); if ($echo) { echo $html; } return $html; }
/** * Creates an ICAL file of events in the database * @since 1.0.0 * @param string filename - the name of the file to be created * @param string filetype - the type of the file ('text/calendar') */ public function export_events($filename, $filetype) { //Collect output ob_start(); // File header header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=' . $filename); header('Content-type: text/calendar; charset=' . get_option('blog_charset') . ';'); header("Pragma: 0"); header("Expires: 0"); eo_locate_template('ical.php', true, false); //Collect output and echo $eventsical = ob_get_contents(); ob_end_clean(); echo $eventsical; exit; }