function eventorganiser_event_fill_columns($column_name, $id) { global $post; $series_id = empty($post->event_id) ? $id : ''; $phpFormat = 'M, j Y'; if (!eo_is_all_day($series_id)) { $phpFormat .= '\\<\\/\\b\\r\\>' . get_option('time_format'); } switch ($column_name) { case 'venue': $venue_id = eo_get_venue($post->ID); $venue_slug = eo_get_venue_slug($post->ID); if ($venue_id) { echo '<a href="' . add_query_arg('event-venue', $venue_slug) . '">' . esc_html(eo_get_venue_name($venue_id)) . '</a>'; echo '<input type="hidden" value="' . $venue_id . '"/>'; } break; case 'datestart': eo_the_start($phpFormat, $series_id); break; case 'dateend': eo_the_end($phpFormat, $series_id); break; case 'reoccurence': eo_display_reoccurence($series_id); break; case 'eventcategories': $terms = get_the_terms($post->ID, 'event-category'); if (!empty($terms)) { foreach ($terms as $term) { $post_terms[] = '<a href="' . add_query_arg('event-category', $term->slug) . '">' . esc_html(sanitize_term_field('name', $term->name, $term->term_id, 'event-category', 'display')) . '</a>'; } echo join(', ', $post_terms); } break; default: break; } // end switch }
function eventorganiser_posterboard_ajax_response() { $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; $query = empty($_GET['query']) ? array() : $_GET['query']; foreach (array('category', 'tag', 'venue') as $tax) { if (isset($query['event_' . $tax])) { $query['event-' . $tax] = $query['event_' . $tax]; unset($query['event_' . $tax]); } } if (isset($query['event-venue']) && '%this%' == $query['event-venue']) { if (eo_get_venue_slug()) { $query['event-venue'] = eo_get_venue_slug(); } else { unset($query['event-venue']); } } if (isset($query['users_events']) && 'true' == strtolower($query['users_events'])) { $query['bookee_id'] = get_current_user_id(); } $query = array_merge(array('event_start_after' => 'today', 'posts_per_page' => 10), $query, array('post_type' => 'event', 'paged' => $page, 'post_status' => array('publish', 'private'), 'perm' => 'readable', 'supress_filters' => false)); $event_query = new WP_Query($query); $response = array(); if ($event_query->have_posts()) { global $post; while ($event_query->have_posts()) { $event_query->the_post(); $start_format = get_option('time_format'); if (eo_get_the_start('Y-m-d') == eo_get_the_end('Y-m-d')) { $end_format = get_option('time_format'); } else { $end_format = 'j M ' . get_option('time_format'); } $venue_id = eo_get_venue(); $categories = get_the_terms(get_the_ID(), 'event-category'); $colour = eo_get_event_color() ? eo_get_event_color() : '#1e8cbe'; $address = eo_get_venue_address($venue_id); $event = array('event_id' => get_the_ID(), 'occurrence_id' => $post->occurrence_id, 'event_title' => get_the_title(), 'event_color' => $colour, 'event_color_light' => eo_color_luminance($colour, 0.3), 'event_start_day' => eo_get_the_start('j'), 'event_start_month' => eo_get_the_start('M'), 'event_content' => get_the_content(), 'event_excerpt' => get_the_excerpt(), 'event_thumbnail' => get_the_post_thumbnail(get_the_ID(), array('200', '200'), array('class' => 'aligncenter')), 'event_permalink' => get_permalink(), 'event_categories' => get_the_term_list(get_the_ID(), 'event-category', '#', ', #', ''), 'event_venue' => $venue_id ? eo_get_venue_name($venue_id) : false, 'event_venue_id' => $venue_id, 'event_venue_city' => $venue_id ? $address['city'] : false, 'event_venue_state' => $venue_id ? $address['state'] : false, 'event_venue_country' => $venue_id ? $address['country'] : false, 'event_venue_url' => $venue_id ? eo_get_venue_link($venue_id) : false, 'event_is_all_day' => eo_is_all_day(), 'event_cat_ids' => $categories ? array_values(wp_list_pluck($categories, 'term_id')) : array(0), 'event_range' => eo_get_the_start($start_format) . ' - ' . eo_get_the_end($end_format)); $event = apply_filters('eventorganiser_posterboard_item', $event, $event['event_id'], $event['occurrence_id']); $response[] = $event; } } wp_reset_postdata(); echo json_encode($response); exit; }
/** * Returns the mark-up for a Google map of the venue (and enqueues scripts). * Accepts an arguments array corresponding to the attributes supported by the shortcode. * * ### Examples * <code> * // Display map of two venues * <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?> * </code> * @since 1.6 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map() * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty. * @return string The markup of the map. False is no venue found. */ function eo_get_venue_map($venue_slug_or_id = '', $args = array()) { //Cast as array to allow multi venue support if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) { $all_venues = eo_get_venues(); if ($all_venues) { $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id')); } } if (!is_array($venue_slug_or_id)) { $venue_slug_or_id = array($venue_slug_or_id); } $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id); //Map properties $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true, 'styles' => array()), $args); //Cast zoom as integer $args['zoom'] = (int) $args['zoom']; //Escape attributes $width = esc_attr($args['width']); $height = esc_attr($args['height']); $class = esc_attr($args['class']); $args['maptypeid'] = strtoupper($args['maptypeid']); //If class is selected use that style, otherwise use specified height and width if (!empty($class)) { $class .= " eo-venue-map googlemap"; $style = ""; } else { $class = "eo-venue-map googlemap"; $style = "style='height:" . $height . ";width:" . $width . ";' "; } $venue_ids = array_filter($venue_ids); if (empty($venue_ids)) { return false; } //Set up venue locations for map foreach ($venue_ids as $venue_id) { //Venue lat/lng array $latlng = eo_get_venue_latlng($venue_id); //Venue tooltip description $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>'; $address = array_filter(eo_get_venue_address($venue_id)); if (!empty($address)) { $tooltip_content .= '<br />' . implode(', ', $address); } /** * Filters the tooltip content for a venue. * * ### Example * * //Adds a link to the venue page to the tooltip * add_filter( 'eventorganiser_venue_tooltip', 'my_venue_tooltip_content_link_to_venue', 10, 2 ); * function my_venue_tooltip_content_link_to_venue( $description, $venue_id ){ * $description .= sprintf('<p><a href="%s"> Visit the venue page! </a> </p>', eo_get_venue_link($venue_id)); * return $description; * } * * @link https://gist.github.com/stephenharris/4988307 Add upcoming events to the the tooltip * @param string $tooltip_content The HTML content for the venue tooltip. * @param int $venue_id The ID of the venue. * @param array $args An array of map options. See documentation for `eo_get_venue_map()`. */ $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args); /** * Filters the url of the venue map marker. Set to `null` for default. * * @link http://wp-event-organiser.com/extensions/event-organiser-venue-markers Custom venue markers * @param string|null $icon Url to the icon image. Null to use default. * @param int $venue_id The ID of the venue. * @param array $args An array of map options. See documentation for `eo_get_venue_map()`. */ $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args); $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon); } $map = array_merge($args, array('locations' => $locations)); /** * Filters the tooltip content for a venue. * * ### Example * * //Styles your google map * add_filter( 'eventorganiser_venue_map_options', 'style_my_google_map', 10 ); * function style_my_google_map( $map_args ){ * $map_args['styles'] = {set styles};; * return $map_args; * } * * @link https://developers.google.com/maps/documentation/javascript/styling#styling_the_default_map * @param array $map Array of map properties, including the key 'location' (array of locations) * height, width, zoom and styles. */ $map = apply_filters('eventorganiser_venue_map_options', $map); //This could be improved EventOrganiser_Shortcodes::$map[] = $map; EventOrganiser_Shortcodes::$add_script = true; $id = count(EventOrganiser_Shortcodes::$map); return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>"; }
/** * 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'); header("Pragma: 0"); header("Expires: 0"); ?> BEGIN:VCALENDAR VERSION:2.0 PRODID:-//<?php get_bloginfo('name'); ?> //NONSGML Events //EN CALSCALE:GREGORIAN X-WR-CALNAME:<?php echo get_bloginfo('name'); ?> - Events X-ORIGINAL-URL:<?php echo EO_Event::link_structure(); ?> X-WR-CALDESC:<?php echo get_bloginfo('name'); ?> - Events <?php // Query for events $events = eo_get_events(array('numberofposts' => -1, 'group_events_by' => 'series', 'showpastevents' => 1)); // Loop through events if ($events) { global $post; foreach ($events as $post) { //If event has no corresponding row in events table then skip it if (!isset($post->event_id) || $post->event_id == -1) { continue; } $now = new DateTime(); $dtstamp = $now->format('Ymd\\THis\\Z'); //Set up event data setup_postdata($post); $event = new EO_Event($post->ID); $start = clone $event->start; $end = clone $event->end; $created = new DateTime($post->post_date_gmt); $created_date = $created->format('Ymd\\THis\\Z'); $modified = new DateTime($post->post_modified_gmt); $modified_date = $modified->format('Ymd\\THis\\Z'); //Set up start and end date times if ($event->is_all_day()) { $format = 'Ymd'; $start_date = $start->format($format); $end->modify('+1 second'); $end_date = $end->format($format); } else { $format = 'Ymd\\THis\\Z'; $UTC_tz = new DateTimeZone('UTC'); $start->setTimezone($UTC_tz); $start_date = $start->format($format); $end->setTimezone($UTC_tz); $end_date = $end->format($format); } //Get the reoccurrence rule in ICS format $reoccurrence_rule = $event->ics_rrule(); //Generate Event status if (get_post_status($post->ID) == 'publish') { $status = 'CONFIRMED'; } else { $status = 'TENTATIVE'; } //Generate a globally unique UID: $rand = ''; $host = $_SERVER['SERVER_NAME']; $base = 'aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPrRsStTuUvVxXuUvVwWzZ1234567890'; $start = 0; $end = strlen($base) - 1; $length = 6; for ($p = 0; $p < $length; $p++) { $rand .= $base[mt_rand($start, $end)]; } $uid = $now->format('Ymd\\THiT') . microtime(true) . '-' . $rand . '-EO' . $post->ID . '@' . $host; //Output event ?> BEGIN:VEVENT UID:<?php echo $uid; ?> STATUS:<?php echo $status; ?> DTSTAMP:<?php echo $dtstamp; ?> CREATED:<?php echo $created_date; ?> LAST-MODIFIED:<?php echo $modified_date; ?> <?php if ($event->is_all_day()) { ?> DTSTART;VALUE=DATE:<?php echo $start_date; ?> DTEND;VALUE=DATE:<?php echo $end_date; } else { ?> DTSTART:<?php echo $start_date; ?> DTEND:<?php echo $end_date; } ?> <?php if ($reoccurrence_rule) { ?> RRULE:<?php echo $reoccurrence_rule; ?> <?php } ?> SUMMARY:<?php echo $this->escape_icalText(get_the_title()); ?> <?php $excerpt = get_the_excerpt(); $excerpt = apply_filters('the_excerpt_rss', $excerpt); if (!empty($excerpt)) { ?> DESCRIPTION:<?php echo html_entity_decode($this->escape_icalText($excerpt)); ?> <?php } if ($event->venue_set()) { $venue = eo_get_venue_name(eo_get_venue()); ?> LOCATION: <?php echo $this->escape_icalText($venue); ?> <?php } $author = get_the_author(); ?> ORGANIZER: <?php echo $this->escape_icalText($author); ?> END:VEVENT <?php } } ?> END:VCALENDAR <?php //Collect output and echo $eventsical = ob_get_contents(); ob_end_clean(); echo $eventsical; exit; }
<?php } else { ?> <!-- Event is not an all day event - display time --> <?php eo_the_start('d F Y g:ia'); ?> <?php } ?> <!-- If the event has a venue saved, display this--> <?php if (eo_get_venue_name()) { ?> <?php _e('at', 'eventorganiser'); ?> <a href="<?php eo_venue_link(); ?> "><?php eo_venue_name(); ?> </a> <?php } ?> </div><!-- .entry-meta -->
function eventorganiser_admin_calendar() { //request $request = array('event_end_after' => $_GET['start'], 'event_start_before' => $_GET['end']); //Presets $presets = array('posts_per_page' => -1, 'post_type' => 'event', 'group_events_by' => '', 'perm' => 'readable'); //Create query $query_array = array_merge($presets, $request); $query = new WP_Query($query_array); //Retrieve events $query->get_posts(); $eventsarray = array(); //Blog timezone $tz = eo_get_blog_timezone(); //Loop through events global $post; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $event = array(); $colour = ''; //Get title, append status if applicable $title = get_the_title(); if (!empty($post->post_password)) { $title .= ' - ' . __('Protected'); } elseif ($post->post_status == 'private') { $title .= ' - ' . __('Private'); } elseif ($post->post_status == 'draft') { $title .= ' - ' . __('Draft'); } $event['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); //Check if all day, set format accordingly if (eo_is_all_day()) { $event['allDay'] = true; $format = get_option('date_format'); } else { $event['allDay'] = false; $format = get_option('date_format') . ' ' . get_option('time_format'); } //Get author (or organiser) $organiser = get_userdata($post->post_author)->display_name; //Get Event Start and End date, set timezone to the blog's timzone $event_start = new DateTime($post->StartDate . ' ' . $post->StartTime, $tz); $event_end = new DateTime($post->EndDate . ' ' . $post->FinishTime, $tz); $event['start'] = $event_start->format('Y-m-d\\TH:i:s\\Z'); $event['end'] = $event_end->format('Y-m-d\\TH:i:s\\Z'); //Produce summary of event $summary = "<table>" . "<tr><th> " . __('Start', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_start, $format) . "</td></tr>" . "<tr><th> " . __('End', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_end, $format) . "</td></tr>" . "<tr><th> " . __('Organiser', 'eventorganiser') . ": </th><td>" . $organiser . "</td></tr>"; $event['className'] = array('event'); $now = new DateTIme(null, $tz); if ($event_start <= $now) { $event['className'][] = 'past-event'; } //Include venue if this is set $venue = eo_get_venue($post->ID); if ($venue && !is_wp_error($venue)) { $summary .= "<tr><th>" . __('Where', 'eventorganiser') . ": </th><td>" . eo_get_venue_name($venue) . "</td></tr>"; $event['className'][] = 'venue-' . eo_get_venue_slug($post->ID); $event['venue'] = $venue; } $summary = apply_filters('eventorganiser_admin_cal_summary', $summary, $post->ID, $post->event_id, $post); $summary .= "</table><p>"; //Include schedule summary if event reoccurrs if ($post->event_schedule != 'once') { $summary .= '<em>' . __('This event reoccurs', 'eventorganiser') . ' ' . eo_get_schedule_summary() . '</em>'; } $summary .= '</p>'; //Include edit link in summary if user has permission if (current_user_can('edit_event', $post->ID)) { $edit_link = get_edit_post_link($post->ID, ''); $summary .= "<span class='edit'><a title='Edit this item' href='" . $edit_link . "'> " . __('Edit Event', 'eventorganiser') . "</a></span>"; $event['url'] = $edit_link; } //Include a delete occurrence link in summary if user has permission if (current_user_can('delete_event', $post->ID)) { $admin_url = admin_url('edit.php'); $delete_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->event_id, 'action' => 'delete_occurrence'), $admin_url); $delete_url = wp_nonce_url($delete_url, 'eventorganiser_delete_occurrence_' . $post->event_id); $summary .= "<span class='delete'>\n\t\t\t\t\t<a class='submitdelete' style='color:red;float:right' title='" . __('Delete this occurrence', 'eventorganiser') . "' href='" . $delete_url . "'> " . __('Delete this occurrence', 'eventorganiser') . "</a>\n\t\t\t\t\t</span>"; if ($post->event_schedule != 'once') { $break_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->event_id, 'action' => 'break_series'), $admin_url); $break_url = wp_nonce_url($break_url, 'eventorganiser_break_series_' . $post->event_id); $summary .= "<span class='break'>\n\t\t\t\t\t\t<a class='submitbreak' style='color:red;float:right;padding-right: 2em;' title='" . __('Break this series', 'eventorganiser') . "' href='" . $break_url . "'> " . __('Break this series', 'eventorganiser') . "</a>\n\t\t\t\t\t\t</span>"; } } $terms = get_the_terms($post->ID, 'event-category'); $event['category'] = array(); if ($terms) { foreach ($terms as $term) { $event['category'][] = $term->slug; if (empty($event['color'])) { $event['color'] = isset($term->color) ? $term->color : ''; } $event['className'][] = 'category-' . $term->slug; } } $event['summary'] = $summary; //Add event to array $eventsarray[] = $event; } } //Echo result and exit echo json_encode($eventsarray); exit; }
static function parse_template($matches) { global $post; $replacement = ''; switch ($matches[1]) { case 'event_title': $replacement = get_the_title(); break; case 'start': case 'end': case 'schedule_start': case 'schedule_last': case 'schedule_end': switch (count($matches)) { case 2: $dateFormat = get_option('date_format'); $dateTime = get_option('time_format'); break; case 3: $dateFormat = self::eo_clean_input($matches[2]); $dateTime = ''; break; case 5: $dateFormat = self::eo_clean_input($matches[3]); $dateTime = self::eo_clean_input($matches[4]); break; } $format = eo_is_all_day(get_the_ID()) ? $dateFormat : $dateFormat . $dateTime; switch ($matches[1]) { case 'start': $replacement = eo_get_the_start($format); break; case 'end': $replacement = eo_get_the_end($format); break; case 'schedule_start': $replacement = eo_get_schedule_start($format); break; case 'schedule_last': case 'schedule_end': $replacement = eo_get_schedule_end($format); break; } break; case 'event_duration': $start = eo_get_the_start(DATETIMEOBJ); $end = clone eo_get_the_end(DATETIMEOBJ); if (eo_is_all_day()) { $end->modify('+1 minute'); } if (function_exists('date_diff')) { $duration = date_diff($start, $end); $replacement = $duration->format($matches[2]); } else { $replacement = eo_date_interval($start, $end, $matches[2]); } $replacement = false; break; case 'event_tags': $replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); break; case 'event_cats': $replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', ''); break; case 'event_venue': $replacement = eo_get_venue_name(); break; case 'event_venue_map': if (eo_get_venue()) { $class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $class = !empty($class) ? 'class=' . $class : ''; $replacement = eo_get_venue_map(eo_get_venue(), compact('class')); } break; case 'event_venue_url': $venue_link = eo_get_venue_link(); $replacement = !is_wp_error($venue_link) ? $venue_link : ''; break; case 'event_venue_address': $address = eo_get_venue_address(); $replacement = $address['address']; break; case 'event_venue_postcode': $address = eo_get_venue_address(); $replacement = $address['postcode']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_venue_country': $address = eo_get_venue_address(); $replacement = $address['country']; break; case 'event_venue_state': $address = eo_get_venue_address(); $replacement = $address['state']; break; case 'event_venue_city': $address = eo_get_venue_address(); $replacement = $address['city']; break; case 'event_thumbnail': $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $size = !empty($size) ? $size : 'thumbnail'; $attr = isset($matches[3]) ? self::eo_clean_input($matches[3]) : ''; //Decode HTML entities as shortcode encodes them $attr = html_entity_decode($attr); $replacement = get_the_post_thumbnail(get_the_ID(), $size, $attr); break; case 'event_url': $replacement = get_permalink(); break; case 'event_custom_field': $field = $matches[2]; $meta = get_post_meta(get_the_ID(), $field); $replacement = implode($meta); break; case 'event_excerpt': $length = isset($matches[2]) ? intval($matches[2]) : 55; //Using get_the_excerpt adds a link.... if (post_password_required($post)) { $output = __('There is no excerpt because this is a protected post.'); } else { $output = $post->post_excerpt; } $replacement = eventorganiser_trim_excerpt($output, $length); break; case 'event_content': $replacement = get_the_content(); break; case 'cat_color': $replacement = eo_get_event_color(); break; case 'event_title_attr': $replacement = get_the_title(); break; } return $replacement; }
/** * Returns HTML mark-up for a list of event meta information. * * Uses microformat. * @since 1.7 * @ignore * @param int $post_id The event (post) ID. Uses current event if not supplied * @return string|bool HTML mark-up. False if an invalid $post_is provided. */ function eo_get_event_meta_list($event_id = 0) { $event_id = (int) (empty($event_id) ? get_the_ID() : $event_id); if (empty($event_id)) { return false; } $html = '<ul class="eo-event-meta" style="margin:10px 0px;">'; $venue = get_taxonomy('event-venue'); if (($venue_id = eo_get_venue($event_id)) && $venue) { $html .= sprintf('<li><strong>%s:</strong> <a href="%s"> <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/Organization"> <span itemprop="name">%s</span> <span itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> <meta itemprop="latitude" content="%f" /> <meta itemprop="longitude" content="%f" /> </span> </span> </a></li>', $venue->labels->singular_name, eo_get_venue_link($venue_id), eo_get_venue_name($venue_id), eo_get_venue_lat($venue_id), eo_get_venue_lng($venue_id)); } if (get_the_terms($event_id, 'event-category')) { $html .= sprintf('<li><strong>%s:</strong> %s</li>' . "\n", __('Categories', 'eventorganiser'), get_the_term_list($event_id, 'event-category', '', ', ', '')); } if (get_the_terms($event_id, 'event-tag') && !is_wp_error(get_the_terms($event_id, 'event-tag'))) { $html .= sprintf('<li><strong>%s:</strong> %s</li>' . "\n", __('Tags', 'eventorganiser'), get_the_term_list($event_id, 'event-tag', '', ', ', '')); } $html .= '</ul>'; /** * Filters mark-up for the event details list. * * The event details list is just a simple list containig details pertaining * to the event (venue, categories, tags) etc. * * @param array $html The generated mark-up * @param int $event_id Post ID of the event */ $html = apply_filters('eventorganiser_event_meta_list', $html, $event_id); return $html; }
/** * Returns the mark-up for a Google map of the venue (and enqueues scripts). * Accepts an arguments array corresponding to the attributes supported by the shortcode. * * ### Examples * <code> * // Display map of two venues * <?php echo eo_get_venue_map(array('london-eye','edinburgh-castle')); ?> * </code> * @since 1.6 * @link http://wp-event-organiser.com/blog/tutorial/changing-the-venue-map-icon/ Changing the venue map icon * @link http://www.stephenharris.info/2012/event-organiser-1-6-whats-new/ Examples of using eo_get_venue_map() * @param mixed $venue_slug_or_id The venue ID as an integer. Or Slug as string. Uses venue of current event if empty. * @return string The markup of the map. False is no venue found. */ function eo_get_venue_map($venue_slug_or_id = '', $args = array()) { //Cast as array to allow multi venue support if ($venue_slug_or_id == '%all%' || is_array($venue_slug_or_id) && in_array('%all%', $venue_slug_or_id)) { $all_venues = eo_get_venues(); if ($all_venues) { $venue_slug_or_id = array_map('intval', wp_list_pluck($all_venues, 'term_id')); } } if (!is_array($venue_slug_or_id)) { $venue_slug_or_id = array($venue_slug_or_id); } $venue_ids = array_map('eo_get_venue_id_by_slugorid', $venue_slug_or_id); //Map properties $args = shortcode_atts(array('zoom' => 15, 'scrollwheel' => true, 'zoomcontrol' => true, 'rotatecontrol' => true, 'pancontrol' => true, 'overviewmapcontrol' => true, 'streetviewcontrol' => true, 'maptypecontrol' => true, 'draggable' => true, 'maptypeid' => 'ROADMAP', 'width' => '100%', 'height' => '200px', 'class' => '', 'tooltip' => true), $args); //Cast zoom as integer $args['zoom'] = (int) $args['zoom']; //Escape attributes $width = esc_attr($args['width']); $height = esc_attr($args['height']); $class = esc_attr($args['class']); $args['maptypeid'] = strtoupper($args['maptypeid']); //If class is selected use that style, otherwise use specified height and width if (!empty($class)) { $class .= " eo-venue-map googlemap"; $style = ""; } else { $class = "eo-venue-map googlemap"; $style = "style='height:" . $height . ";width:" . $width . ";' "; } $venue_ids = array_filter($venue_ids); if (empty($venue_ids)) { return false; } //Set up venue locations for map foreach ($venue_ids as $venue_id) { //Venue lat/lng array $latlng = eo_get_venue_latlng($venue_id); //Venue tooltip description $tooltip_content = '<strong>' . eo_get_venue_name($venue_id) . '</strong>'; $address = array_filter(eo_get_venue_address($venue_id)); if (!empty($address)) { $tooltip_content .= '<br />' . implode(', ', $address); } $tooltip_content = apply_filters('eventorganiser_venue_tooltip', $tooltip_content, $venue_id, $args); $icon = apply_filters('eventorganiser_venue_marker', null, $venue_id, $args); $locations[] = array('venue_id' => $venue_id, 'lat' => $latlng['lat'], 'lng' => $latlng['lng'], 'tooltipContent' => $tooltip_content, 'icon' => $icon); } //This could be improved EventOrganiser_Shortcodes::$map[] = array_merge($args, array('locations' => $locations)); EventOrganiser_Shortcodes::$add_script = true; $id = count(EventOrganiser_Shortcodes::$map); return "<div class='" . $class . "' id='eo_venue_map-{$id}' " . $style . "></div>"; }
/** * Returns HTML mark-up for a list of event meta information. * * Uses microformat. * @since 1.7 * @ignore * @param int $post_id The event (post) ID. Uses current event if not supplied * @return string|bool HTML mark-up. False if an invalid $post_is provided. */ function eo_get_event_meta_list_rcumc($event_id = 0) { $event_id = (int) (empty($event_id) ? get_the_ID() : $event_id); if (empty($event_id)) { return false; } $html = '<ul class="eo-event-byline" style="margin:10px 0px;">'; $venue = get_taxonomy('event-venue'); if (($venue_id = eo_get_venue($event_id)) && $venue) { $html .= sprintf('<ul> <a href="%s"> <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/Organization"> <span itemprop="name">%s</span> </span> </a></ul>', eo_get_venue_link($venue_id), eo_get_venue_name($venue_id)); } $html .= '</ul>'; /** * Filters mark-up for the event details list. * * The event details list is just a simple list containing details pertaining * to the event (venue, categories, tags) etc. * * @param array $html The generated mark-up * @param int $event_id Post ID of the event */ $html = apply_filters('eventorganiser_event_meta_list', $html, $event_id); return $html; }
/** * Returns a the url which adds a particular occurrence of an event to * a google calendar. * Must be used inside the loop * * @since 1.2.0 */ function eo_get_the_GoogleLink() { global $post; setup_postdata($post); if (empty($post) || get_post_type($post) != 'event') { return false; } $startDT = new DateTime($post->StartDate . ' ' . $post->StartTime, eo_get_blog_timezone()); $endDT = new DateTime($post->EndDate . ' ' . $post->FinishTime, eo_get_blog_timezone()); if (eo_is_allday()) { $endDT->modify('+1 second'); $format = 'Ymd'; } else { $format = 'Ymd\\THis\\Z'; $startDT->setTimezone(new DateTimeZone('UTC')); $endDT->setTimezone(new DateTimeZone('UTC')); } $excerpt = get_the_excerpt(); $excerpt = apply_filters('the_excerpt_rss', $excerpt); $excerpt = esc_html($excerpt); $url = add_query_arg(array('text' => $post->post_title, 'dates' => $startDT->format($format) . '/' . $endDT->format($format), 'trp' => false, 'details' => $excerpt, 'sprop' => get_bloginfo('name')), 'http://www.google.com/calendar/event?action=TEMPLATE'); if ($post->Venue) { $venue = eo_get_venue_name((int) $post->Venue) . ", " . implode(', ', eo_get_venue_address((int) $post->Venue)); $url = add_query_arg('location', $venue, $url); } wp_reset_postdata(); return $url; }
eo_venue_name(); ?> </h4> </div> <?php } ?> <?php the_content(); ?> <?php if (eo_get_venue()) { $location = explode(',', eo_get_venue_name(), 2); echo do_shortcode("[google-map-sc width=100% height=300 zoom=15 type=ROADMAP address='" . $location[1] . "']"); } ?> <?php echo do_shortcode('[button url="http://www.buildinstitute.com/events/" arrow="left"]All Events[/button]'); ?> <?php } } ?> </main>
/** * Returns HTML mark-up for a list of event meta information. * * Uses microformat. * @since 1.7 * @ignore * @param int $post_id The event (post) ID. Uses current event if not supplied * @return string|bool HTML mark-up. False if an invalid $post_is provided. */ function eo_get_event_meta_list($post_id = 0) { $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id); if (empty($post_id)) { return false; } $html = '<ul class="eo-event-meta" style="margin:10px 0px;">'; if ($venue_id = eo_get_venue($post_id)) { $html .= sprintf('<li><strong>%s:</strong> <a href="%s"> <span itemprop="location" itemscope itemtype="http://data-vocabulary.org/Organization"> <span itemprop="name">%s</span> <span itemprop="geo" itemscope itemtype="http://data-vocabulary.org/Geo"> <meta itemprop="latitude" content="%f" /> <meta itemprop="longitude" content="%f" /> </span> </span></a></li>', __('Venue', 'eventorganiser'), eo_get_venue_link($venue_id), eo_get_venue_name($venue_id), eo_get_venue_lat($venue_id), eo_get_venue_lng($venue_id)); } if (get_the_terms(get_the_ID(), 'event-category')) { $html .= sprintf('<li><strong>%s:</strong> %s</li>', __('Categories', 'eventorganiser'), get_the_term_list(get_the_ID(), 'event-category', '', ', ', '')); } if (get_the_terms(get_the_ID(), 'event-tag') && !is_wp_error(get_the_terms(get_the_ID(), 'event-tag'))) { $html .= sprintf('<li><strong>%s:</strong> %s</li>', __('Tags', 'eventorganiser'), get_the_term_list(get_the_ID(), 'event-tag', '', ', ', '')); } $html .= '</ul>'; return apply_filters('eventorganiser_event_meta_list', $html, $post_id); }
function parse_template($matches) { global $post; $replacement = ''; $col = array('start' => array('date' => 'StartDate', 'time' => 'StartTime'), 'end' => array('date' => 'EndDate', 'time' => 'FinishTime'), 'schedule_start' => array('date' => 'reoccurrence_start', 'time' => 'StartTime'), 'schedule_end' => array('date' => 'reoccurrence_end', 'time' => 'FinishTime')); switch ($matches[1]) { case 'event_title': $replacement = get_the_title(); break; case 'start': case 'end': case 'schedule_start': case 'schedule_end': switch (count($matches)) { case 2: $dateFormat = get_option('date_format'); $dateTime = get_option('time_format'); break; case 3: $dateFormat = self::eo_clean_input($matches[2]); $dateTime = ''; break; case 5: $dateFormat = self::eo_clean_input($matches[3]); $dateTime = self::eo_clean_input($matches[4]); break; } if (eo_is_all_day(get_the_ID())) { $replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat); } else { $replacement = eo_format_date($post->{$col}[$matches[1]]['date'] . ' ' . $post->{$col}[$matches[1]]['time'], $dateFormat . $dateTime); } break; case 'event_tags': $replacement = get_the_term_list(get_the_ID(), 'event-tag', '', ', ', ''); break; case 'event_cats': $replacement = get_the_term_list(get_the_ID(), 'event-category', '', ', ', ''); break; case 'event_venue': $replacement = eo_get_venue_name(); break; case 'event_venue_map': if (eo_get_venue()) { $class = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $class = !empty($class) ? 'class=' . $class : ''; $replacement = do_shortcode('[eo_venue_map ' . $class . ']'); } break; case 'event_venue_url': $venue_link = eo_get_venue_link(); $replacement = !is_wp_error($venue_link) ? $venue_link : ''; break; case 'event_venue_address': $address = eo_get_venue_address(); $replacement = $address['address']; break; case 'event_venue_postcode': $address = eo_get_venue_address(); $replacement = $address['postcode']; break; case 'event_venue_country': $address = eo_get_venue_address(); $replacement = $address['country']; break; case 'event_thumbnail': $size = isset($matches[2]) ? self::eo_clean_input($matches[2]) : ''; $size = !empty($size) ? $size : 'thumbnail'; $replacement = get_the_post_thumbnail(get_the_ID(), $size); break; case 'event_url': $replacement = get_permalink(); break; case 'event_custom_field': $field = $matches[2]; $meta = get_post_meta(get_the_ID(), $field); $replacement = implode($meta); break; case 'event_excerpt': //Using get_the_excerpt adds a link.... if (post_password_required($post)) { $output = __('There is no excerpt because this is a protected post.'); } else { $output = $post->post_excerpt; } $replacement = wp_trim_excerpt($output); break; case 'cat_color': $replacement = eo_event_color(); break; } return $replacement; }
/** * Ajax response for the admin full calendar. * * This gets events and generates summaries for events to be displayed. * in the admin 'calendar view'. * Applies 'eventorganiser_admin_cal_summary' to event summary * Applies eventorganiser_admin_calendar to the event array * *@since 1.0 *@access private *@ignore */ function eventorganiser_admin_calendar() { //request $request = array('event_end_after' => $_GET['start'], 'event_start_before' => $_GET['end']); //Presets $presets = array('posts_per_page' => -1, 'post_type' => 'event', 'group_events_by' => '', 'perm' => 'readable'); $calendar = get_transient('eo_full_calendar_admin'); $key = $_GET['start'] . '--' . $_GET['end'] . 'u=' . get_current_user_id(); if ((!defined('WP_DEBUG') || !WP_DEBUG) && $calendar && is_array($calendar) && isset($calendar[$key])) { echo json_encode($calendar[$key]); exit; } //Create query $query_array = array_merge($presets, $request); $query = new WP_Query($query_array); //Retrieve events $query->get_posts(); $eventsarray = array(); //Blog timezone $tz = eo_get_blog_timezone(); //Loop through events global $post; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $event = array(); $colour = ''; //Get title, append status if applicable $title = get_the_title(); if (!empty($post->post_password)) { $title .= ' - ' . __('Protected'); } elseif ($post->post_status == 'private') { $title .= ' - ' . __('Private'); } elseif ($post->post_status == 'draft') { $title .= ' - ' . __('Draft'); } $event['title'] = html_entity_decode($title, ENT_QUOTES, 'UTF-8'); $event['event_id'] = $post->ID; $event['occurrence_id'] = $post->occurrence_id; $schedule = eo_get_event_schedule($post->ID); //Check if all day, set format accordingly if ($schedule['all_day']) { $event['allDay'] = true; $format = get_option('date_format'); } else { $event['allDay'] = false; $format = get_option('date_format') . ' ' . get_option('time_format'); } //Get author (or organiser) $organiser = get_userdata($post->post_author)->display_name; //Get Event Start and End date, set timezone to the blog's timzone $event_start = new DateTime($post->StartDate . ' ' . $post->StartTime, $tz); $event_end = new DateTime($post->EndDate . ' ' . $post->FinishTime, $tz); $event['start'] = $event_start->format('Y-m-d\\TH:i:s\\Z'); $event['end'] = $event_end->format('Y-m-d\\TH:i:s\\Z'); //Produce summary of event $summary = "<table class='form-table' >" . "<tr><th> " . __('Start', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_start, $format) . "</td></tr>" . "<tr><th> " . __('End', 'eventorganiser') . ": </th><td> " . eo_format_datetime($event_end, $format) . "</td></tr>"; if (eo_is_multi_event_organiser()) { $summary .= "<tr><th> " . __('Organiser', 'eventorganiser') . ": </th><td>" . $organiser . "</td></tr>"; } $event['className'] = array('event'); $now = new DateTime(null, $tz); if ($event_start <= $now) { $event['className'][] = 'past-event'; } //Include venue if this is set $venue = eo_get_venue($post->ID); if ($venue && !is_wp_error($venue)) { $summary .= "<tr><th>" . __('Where', 'eventorganiser') . ": </th><td>" . eo_get_venue_name($venue) . "</td></tr>"; $event['className'][] = 'venue-' . eo_get_venue_slug($post->ID); $event['venue'] = $venue; } /** * Filters the summary of the event as it appears in the admin * calendar's modal. * * **Note:** As the calendar is cached, changes made using this filter * will not take effect immediately. You can clear the cache by * updating an event. * * @package admin-calendar * @param string $summary The event (admin) summary, * @param int $event_id The event's post ID. * @param int $occurrence_id The event's occurrence ID. * @param WP_Post $post The event (post) object. */ $summary = apply_filters('eventorganiser_admin_cal_summary', $summary, $post->ID, $post->occurrence_id, $post); $summary .= "</table><p>"; //Include schedule summary if event reoccurrs if ($schedule['schedule'] != 'once') { $summary .= '<em>' . __('This event reoccurs', 'eventorganiser') . ' ' . eo_get_schedule_summary() . '</em>'; } $summary .= '</p>'; //Include edit link in summary if user has permission if (current_user_can('edit_event', $post->ID)) { $edit_link = get_edit_post_link($post->ID, ''); $summary .= "<span class='edit'><a title='Edit this item' href='" . $edit_link . "'> " . __('Edit Event', 'eventorganiser') . "</a></span>"; $event['url'] = $edit_link; } //Include a delete occurrence link in summary if user has permission if (current_user_can('delete_event', $post->ID)) { $admin_url = admin_url('edit.php'); $delete_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->occurrence_id, 'action' => 'delete_occurrence'), $admin_url); $delete_url = wp_nonce_url($delete_url, 'eventorganiser_delete_occurrence_' . $post->occurrence_id); $summary .= sprintf('<span class="delete"><a class="submitdelete" style="color:red;float:right" title="%1$s" href="%2$s">%1$s</a></span>', esc_attr__('Delete this occurrence', 'eventorganiser'), $delete_url); if ($schedule['schedule'] != 'once') { $break_url = add_query_arg(array('post_type' => 'event', 'page' => 'calendar', 'series' => $post->ID, 'event' => $post->occurrence_id, 'action' => 'break_series'), $admin_url); $break_url = wp_nonce_url($break_url, 'eventorganiser_break_series_' . $post->occurrence_id); $summary .= sprintf('<span class="break"><a class="submitbreak" style="color:red;float:right;padding-right:2em;" title="%1$s" href="%2$s">%1$s</a></span>', esc_attr__('Break this series', 'eventorganiser'), $break_url); } } //Event categories $terms = get_the_terms($post->ID, 'event-category'); $event['category'] = array(); if ($terms) { foreach ($terms as $term) { $event['category'][] = $term->slug; $event['className'][] = 'category-' . $term->slug; } } //Event colour $event['textColor'] = '#ffffff'; //default text colour if (eo_get_event_color()) { $event['color'] = eo_get_event_color(); $event['textColor'] = eo_get_event_textcolor($event['color']) ? eo_get_event_textcolor($event['color']) : '#ffffff'; } //Event summary $event['summary'] = '<div id="eo-cal-meta">' . $summary . '</div>'; //Filter the event array /** * @ignore */ $event = apply_filters('eventorganiser_admin_calendar', $event, $post); /** * Filters the event before its sent to the admin calendar. * * **Note:** As the calendar is cached, changes made using this filter * will not take effect immediately. You can clear the cache by * updating an event. * * @package admin-calendar * @param array $event The event array. * @param int $event_id The event's post ID. * @param int $occurrence_id The event's occurrence ID. */ $event = apply_filters('eventorganiser_admin_fullcalendar_event', $event, $post->ID, $post->occurrence_id); //Add event to array $eventsarray[] = $event; } } if (!$calendar || !is_array($calendar)) { $calendar = array(); } $calendar[$key] = $eventsarray; set_transient('eo_full_calendar_admin', $calendar, 60 * 60 * 24); //Echo result and exit echo json_encode($eventsarray); exit; }
$description = eventorganiser_escape_ical_text($description); if (!empty($description)) { echo eventorganiser_fold_ical_text("DESCRIPTION: {$description}") . "\r\n"; } $description = wpautop(html_entity_decode(get_the_content(), ENT_COMPAT, 'UTF-8')); $description = str_replace("\r\n", '', $description); //Remove new lines $description = str_replace("\n", '', $description); $description = eventorganiser_escape_ical_text($description); echo eventorganiser_fold_ical_text("X-ALT-DESC;FMTTYPE=text/html: {$description}") . "\r\n"; $cats = get_the_terms(get_the_ID(), 'event-category'); if ($cats && !is_wp_error($cats)) { $cat_names = wp_list_pluck($cats, 'name'); $cat_names = array_map('eventorganiser_escape_ical_text', $cat_names); echo 'CATEGORIES:' . implode(',', $cat_names) . "\r\n"; } if (eo_get_venue()) { $venue = eo_get_venue_name(eo_get_venue()); echo "LOCATION:" . eventorganiser_fold_ical_text(eventorganiser_escape_ical_text($venue)) . "\r\n"; echo "GEO:" . implode(';', eo_get_venue_latlng($venue)) . "\r\n"; } if (get_the_author_meta('ID')) { $author_name = eventorganiser_escape_ical_text(get_the_author()); $author_email = eventorganiser_escape_ical_text(get_the_author_meta('user_email')); echo eventorganiser_fold_ical_text('ORGANIZER;CN="' . $author_name . '":MAILTO:' . $author_email) . "\r\n"; } echo eventorganiser_fold_ical_text('URL;VALUE=URI:' . get_permalink()) . "\r\n"; echo "END:VEVENT\r\n"; } } echo "END:VCALENDAR\r\n";
?> <div class="container"> <div class="row"> <div class="col-md-8"> <div id="primary" role="main" class="content-area"> <!-- Page header, display venue title--> <?php $venue_id = get_queried_object_id(); ?> <h2 class="chesterRed entry"> <?php printf(__('Galas at %s', 'eventorganiser'), '<span>' . eo_get_venue_name($venue_id) . '</span>'); ?> </h2> <hr> <?php if ($venue_description = eo_get_venue_description($venue_id)) { echo '<div class="venue-archive-meta">' . $venue_description . '</div>'; } ?> <!-- Display the venue map. If you specify a class, ensure that class has height/width dimensions--> <?php if (eo_venue_has_latlng($venue_id)) { echo eo_get_venue_map($venue_id, array('width' => '100%'));
/** * Echos the venue of the event * * @uses eo_get_venue_name * @param (int) venue id or (string) venue slug * * @since 1.0.0 */ function eo_venue_name($venue_slug_or_id = '') { echo eo_get_venue_name($venue_slug_or_id); }