function _backend_load_event_of_date() { if (isset($_POST['event_date']) && $_POST['event_date']) { TribeEventsQuery::init(); $states[] = 'publish'; if (0 < get_current_user_id()) { $states[] = 'private'; } $args = array('post_status' => $states, 'eventDate' => $_POST["event_date"], 'eventDisplay' => 'day'); TribeEvents::instance()->displaying = 'day'; $query = TribeEventsQuery::getEvents($args, true); global $wp_query, $post; $wp_query = $query; add_filter('tribe_is_day', '__return_true'); $html = ''; if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $html .= '<option value="' . get_the_ID() . '"> ' . get_the_title() . '</option>'; } wp_reset_postdata(); } $response = array('html' => $html, 'success' => true, 'total_count' => $query->found_posts, 'view' => 'day'); header('Content-type: application/json'); echo json_encode($response); die; } }
/** * AJAX handler for the Map view */ function ajax_response() { $tribe_paged = !empty($_POST['tribe_paged']) ? $_POST['tribe_paged'] : 1; TribeEventsQuery::init(); $defaults = array('post_type' => TribeEvents::POSTTYPE, 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => array('publish'), 'eventDisplay' => 'map'); $view_state = 'map'; /* if past view */ if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $view_state = 'past'; $defaults['eventDisplay'] = 'past'; } if (isset($_POST['tribe_event_category'])) { $defaults[TribeEvents::TAXONOMY] = $_POST['tribe_event_category']; } $query = TribeEventsQuery::getEvents($defaults, true); $have_events = 0 < $query->found_posts; if ($have_events && TribeEventsGeoLoc::instance()->is_geoloc_query()) { $lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0; $lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0; TribeEventsGeoLoc::instance()->assign_distance_to_posts($query->posts, $lat, $lng); } elseif (!$have_events && isset($_POST['tribe-bar-geoloc'])) { TribeEvents::setNotice('event-search-no-results', sprintf(__('No results were found for events in or near <strong>"%s"</strong>.', 'tribe-events-calendar-pro'), esc_html($_POST['tribe-bar-geoloc']))); } elseif (!$have_events && isset($_POST['tribe_event_category'])) { TribeEvents::setNotice('events-not-found', sprintf(__('No matching events listed under %s. Please try viewing the full calendar for a complete list of events.', 'tribe-events-calendar'), esc_html($_POST['tribe_event_category']))); } elseif (!$have_events) { TribeEvents::setNotice('event-search-no-results', __('There were no results found.', 'tribe-events-calendar-pro')); } $response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state); // @TODO: clean this up / refactor the following conditional if ($have_events) { global $wp_query, $post; $data = $query->posts; $post = $query->posts[0]; $wp_query = $query; TribeEvents::instance()->displaying = 'map'; ob_start(); tribe_get_view('pro/map/content'); $response['html'] .= ob_get_clean(); $response['markers'] = TribeEventsGeoLoc::instance()->generate_markers($data); } else { global $wp_query; $wp_query = $query; TribeEvents::instance()->setDisplay(); ob_start(); tribe_get_view('pro/map/content'); $response['html'] .= ob_get_clean(); } $response = apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); exit; }
/** * List view ajax handler * * @return void */ function ajax_response() { TribeEventsQuery::init(); $tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1; $args = array('eventDisplay' => 'list', 'post_type' => TribeEvents::POSTTYPE, 'post_status' => 'publish', 'paged' => $tribe_paged); // check & set past display if (isset($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $args['eventDisplay'] = 'past'; } // check & set event category if (isset($_POST['tribe_event_category'])) { $args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category']; } $query = tribe_get_events($args, true); // $hash is used to detect whether the primary arguments in the query have changed (i.e. due to a filter bar request) // if they have, we want to go back to page 1 $hash = $query->query_vars; $hash['paged'] = null; $hash['start_date'] = null; $hash['end_date'] = null; $hash_str = md5(maybe_serialize($hash)); if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) { $tribe_paged = 1; $args['paged'] = 1; $query = TribeEventsQuery::getEvents($args, true); } $response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'total_count' => $query->found_posts, 'view' => 'list'); global $wp_query, $post, $paged; $wp_query = $query; if (!empty($query->posts)) { $post = $query->posts[0]; } $paged = $tribe_paged; TribeEvents::instance()->displaying = 'list'; if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $response['view'] = 'past'; } ob_start(); tribe_get_view('list/content'); $response['html'] .= ob_get_clean(); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; }
/** * AJAX handler for Photo view * * @return void */ function ajax_response() { $tec = TribeEvents::instance(); TribeEventsQuery::init(); $tribe_paged = !empty($_POST['tribe_paged']) ? intval($_POST['tribe_paged']) : 1; $args = array('eventDisplay' => 'list', 'post_type' => TribeEvents::POSTTYPE, 'post_status' => 'publish', 'paged' => $tribe_paged); $view_state = 'photo'; if (isset($_POST['tribe_event_category'])) { $args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category']; } /* if past view */ if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $view_state = 'past'; $args['eventDisplay'] = 'past'; } $query = TribeEventsQuery::getEvents($args, true); $hash = $query->query_vars; $hash['paged'] = null; $hash['start_date'] = null; $hash_str = md5(maybe_serialize($hash)); if (!empty($_POST['hash']) && $hash_str !== $_POST['hash']) { $tribe_paged = 1; $args['paged'] = 1; $query = TribeEventsQuery::getEvents($args, true); } $response = array('html' => '', 'success' => true, 'max_pages' => $query->max_num_pages, 'hash' => $hash_str, 'tribe_paged' => $tribe_paged, 'view' => $view_state); global $wp_query, $post; $wp_query = $query; if (!empty($query->posts)) { $post = $query->posts[0]; } add_filter('tribe_events_list_pagination', array('TribeEvents', 'clear_module_pagination'), 10); $tec->displaying = 'photo'; ob_start(); tribe_get_view('pro/photo/content'); $response['html'] .= ob_get_clean(); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; }
/** * $Desc * * @version $Id$ * @package wpbase * @author WPOpal Team <wpopal@gmail.com, support@wpopal.com> * @copyright Copyright (C) 2015 wpopal.com. All Rights Reserved. * @license GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html * * @website http://www.wpopal.com * @support http://www.wpopal.com/support/forum.html */ $atts = vc_map_get_attributes($this->getShortcode(), $atts); extract($atts); TribeEventsQuery::init(); $states[] = 'publish'; $args = array('post_status' => $states, 'eventDate' => $event_date, 'eventDisplay' => 'day', 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'tribe_events', 'post__in' => wp_parse_id_list($event_ids)); TribeEvents::instance()->displaying = 'day'; $query = TribeEventsQuery::getEvents($args, true); $_id = training_wpo_makeid(); ?> <div class="widget wpo-event-of-date <?php echo esc_attr($el_class); ?> "> <?php if ($title) { ?> <h3 class="widget-title visual-title <?php echo esc_attr($size) . ' ' . $alignment;
/** * AJAX handler for tribe_event_day (dayview navigation) * This loads up the day view shard with all the appropriate events for the day * * @return void */ function ajax_response() { if (isset($_POST['eventDate']) && $_POST['eventDate']) { TribeEventsQuery::init(); $states[] = 'publish'; if (0 < get_current_user_id()) { $states[] = 'private'; } $args = array('post_status' => $states, 'eventDate' => $_POST["eventDate"], 'eventDisplay' => 'day'); TribeEvents::instance()->displaying = 'day'; if (isset($_POST['tribe_event_category'])) { $args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category']; } $query = TribeEventsQuery::getEvents($args, true); global $wp_query, $post; $wp_query = $query; add_filter('tribe_is_day', '__return_true'); // simplest way to declare that this is a day view ob_start(); tribe_get_view('day/content'); $response = array('html' => ob_get_clean(), 'success' => true, 'total_count' => $query->found_posts, 'view' => 'day'); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; } }
/** * Generates the iCal file * * @static * * @param int|null $post If you want the ical file for a single event */ public static function generate_ical_feed($post = null) { $tec = TribeEvents::instance(); $wp_timezone = get_option('timezone_string'); $events = ''; $blogHome = get_bloginfo('url'); $blogName = get_bloginfo('name'); $event_display = !empty($_REQUEST['tribe_display']) ? $_REQUEST['tribe_display'] : 'upcoming'; if ($event_display == 'list') { $event_display = 'upcoming'; } if ($post) { $events_posts = array(); $events_posts[] = $post; } else { TribeEventsQuery::init(); $events_query = TribeEventsQuery::getEvents(array('posts_per_page' => -1, 'eventDisplay' => $event_display), true); $events_posts = $events_query->posts; } foreach ($events_posts as $event_post) { $startDate = $event_post->EventStartDate; $endDate = $event_post->EventEndDate; // convert 2010-04-08 00:00:00 to 20100408T000000 or YYYYMMDDTHHMMSS $startDate = str_replace(array('-', ' ', ':'), array('', 'T', ''), $startDate); $endDate = str_replace(array('-', ' ', ':'), array('', 'T', ''), $endDate); if (get_post_meta($event_post->ID, '_EventAllDay', true) == 'yes') { $startDate = substr($startDate, 0, 8); $endDate = substr($endDate, 0, 8); // endDate bumped ahead one day to counter iCal's off-by-one error $endDateStamp = strtotime($endDate); $endDate = date('Ymd', $endDateStamp + 86400); $type = 'DATE'; } else { $type = 'DATE-TIME'; } $description = preg_replace("/[\n\t\r]/", ' ', strip_tags($event_post->post_content)); // add fields to iCal output $item = array(); $item[] = "DTSTART;VALUE={$type}:" . $startDate; $item[] = "DTEND;VALUE={$type}:" . $endDate; $item[] = 'DTSTAMP:' . date('Ymd\\THis', time()); $item[] = 'CREATED:' . str_replace(array('-', ' ', ':'), array('', 'T', ''), $event_post->post_date); $item[] = 'LAST-MODIFIED:' . str_replace(array('-', ' ', ':'), array('', 'T', ''), $event_post->post_modified); $item[] = 'UID:' . $event_post->ID . '-' . strtotime($startDate) . '-' . strtotime($endDate) . '@' . $blogHome; $item[] = 'SUMMARY:' . $event_post->post_title; $item[] = 'DESCRIPTION:' . str_replace(',', '\\,', $description); $item[] = 'LOCATION:' . html_entity_decode($tec->fullAddressString($event_post->ID), ENT_QUOTES); $item[] = 'URL:' . get_permalink($event_post->ID); $item = apply_filters('tribe_ical_feed_item', $item, $event_post); $events .= "BEGIN:VEVENT\r\n" . implode("\r\n", $item) . "\r\nEND:VEVENT\r\n"; } header('Content-type: text/calendar; charset=UTF-8'); header('Content-Disposition: attachment; filename="iCal-TribeEvents.ics"'); $content = "BEGIN:VCALENDAR\r\n"; $content .= "VERSION:2.0\r\n"; $content .= 'PRODID:-//' . $blogName . ' - ECPv' . TribeEvents::VERSION . "//NONSGML v1.0//EN\r\n"; $content .= "CALSCALE:GREGORIAN\r\n"; $content .= "METHOD:PUBLISH\r\n"; $content .= 'X-WR-CALNAME:' . apply_filters('tribe_ical_feed_calname', $blogName) . "\r\n"; $content .= 'X-ORIGINAL-URL:' . $blogHome . "\r\n"; $content .= 'X-WR-CALDESC:Events for ' . $blogName . "\r\n"; if ($wp_timezone) { $content .= 'X-WR-TIMEZONE:' . $wp_timezone . "\r\n"; } $content = apply_filters('tribe_ical_properties', $content); $content .= $events; $content .= 'END:VCALENDAR'; echo $content; exit; }
/** * AJAX handler for tribe_event_day (dayview navigation) * This loads up the day view shard with all the appropriate events for the day * * @return void * @author Timothy Wood * @since 3.0 */ function wp_ajax_tribe_event_day() { if (isset($_POST["eventDate"]) && $_POST["eventDate"]) { if (class_exists('TribeEventsFilterView')) { TribeEventsFilterView::instance()->createFilters(null, true); } TribeEventsQuery::init(); add_filter('tribe_events_pre_get_posts', array($this, 'pre_get_posts')); $args = array('post_status' => array('publish', 'private', 'future'), 'eventDate' => $_POST["eventDate"], 'eventDisplay' => 'day'); if (isset($_POST['tribe_event_category'])) { $args[TribeEvents::TAXONOMY] = $_POST['tribe_event_category']; } $query = TribeEventsQuery::getEvents($args, true); global $wp_query, $post; $wp_query = $query; if (have_posts()) { the_post(); // TODO: why is this here? rewind_posts(); // so we don't skip the first post when rendering } add_filter('tribe_is_day', '__return_true'); // simplest way to declare that this is a day view TribeEventsTemplates::getTemplateHierarchy('day', '', 'pro', $this->pluginPath); ob_start(); tribe_get_view('day/content'); $response = array('html' => ob_get_clean(), 'success' => true, 'total_count' => $query->found_posts, 'view' => 'day'); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; } }
/** * Run on applied action init */ public function init() { $this->loadTextDomain(); $this->pluginName = __('The Events Calendar', 'tribe-events-calendar'); $this->rewriteSlug = sanitize_title($this->getOption('eventsSlug', 'events')); $this->rewriteSlugSingular = sanitize_title($this->getOption('singleEventSlug', 'event')); $this->taxRewriteSlug = $this->rewriteSlug . '/' . sanitize_title(__('category', 'tribe-events-calendar')); $this->tagRewriteSlug = $this->rewriteSlug . '/' . sanitize_title(__('tag', 'tribe-events-calendar')); $this->monthSlug = sanitize_title(__('month', 'tribe-events-calendar')); $this->upcomingSlug = sanitize_title(__('upcoming', 'tribe-events-calendar')); $this->pastSlug = sanitize_title(__('past', 'tribe-events-calendar')); $this->postTypeArgs['rewrite']['slug'] = sanitize_title($this->rewriteSlugSingular); $this->postVenueTypeArgs['rewrite']['slug'] = sanitize_title(__('venue', 'tribe-events-calendar')); $this->postVenueTypeArgs['show_in_nav_menus'] = class_exists('TribeEventsPro') ? true : false; $this->currentDay = ''; $this->errors = ''; TribeEventsQuery::init(); $this->registerPostType(); //If the custom post type's rewrite rules have not been generated yet, flush them. (This can happen on reactivations.) if (is_array(get_option('rewrite_rules')) && !array_key_exists($this->rewriteSlugSingular . '/[^/]+/([^/]+)/?$', get_option('rewrite_rules'))) { TribeEvents::flushRewriteRules(); } self::debug(sprintf(__('Initializing Tribe Events on %s', 'tribe-events-calendar'), date('M, jS \\a\\t h:m:s a'))); $this->maybeMigrateDatabase(); $this->maybeRenameOptions(); $this->maybeSetTECVersion(); }
/** * The Calendar View AJAX Handler. * * @return void * @since 3.0 */ function calendar_ajax_call() { if (isset($_POST["eventDate"]) && $_POST["eventDate"]) { TribeEventsQuery::init(); // set the global query var for eventDisplay $query_args = array('post_type' => self::POSTTYPE, 'eventDisplay' => 'month', 'eventDate' => $_POST['eventDate']); $this->displaying = 'month'; if (isset($_POST['tribe_event_category'])) { $query_args['tribe_events_cat'] = $_POST['tribe_event_category']; } query_posts($query_args); ob_start(); tribe_get_view('month/content'); $response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month'); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; } }
/** * Run on applied action init */ public function init() { $this->pluginName = __('The Events Calendar', 'tribe-events-calendar'); $this->rewriteSlug = $this->getRewriteSlug(); $this->rewriteSlugSingular = $this->getRewriteSlugSingular(); $this->taxRewriteSlug = $this->getTaxRewriteSlug(); $this->tagRewriteSlug = $this->getTagRewriteSlug(); $this->monthSlug = sanitize_title(__('month', 'tribe-events-calendar')); $this->listSlug = sanitize_title(__('list', 'tribe-events-calendar')); $this->upcomingSlug = sanitize_title(__('upcoming', 'tribe-events-calendar')); $this->pastSlug = sanitize_title(__('past', 'tribe-events-calendar')); $this->daySlug = sanitize_title(__('day', 'tribe-events-calendar')); $this->todaySlug = sanitize_title(__('today', 'tribe-events-calendar')); $this->singular_venue_label = $this->get_venue_label_singular(); $this->plural_venue_label = $this->get_venue_label_plural(); $this->singular_organizer_label = $this->get_organizer_label_singular(); $this->plural_organizer_label = $this->get_organizer_label_plural(); $this->postTypeArgs['rewrite']['slug'] = sanitize_title($this->rewriteSlugSingular); $this->postVenueTypeArgs['rewrite']['slug'] = sanitize_title($this->singular_venue_label); $this->postVenueTypeArgs['show_in_nav_menus'] = class_exists('TribeEventsPro') ? true : false; $this->postOrganizerTypeArgs['rewrite']['slug'] = sanitize_title($this->singular_organizer_label); $this->postOrganizerTypeArgs['show_in_nav_menus'] = class_exists('TribeEventsPro') ? true : false; $this->postVenueTypeArgs['public'] = class_exists('TribeEventsPro') ? true : false; $this->postOrganizerTypeArgs['public'] = class_exists('TribeEventsPro') ? true : false; $this->currentDay = ''; $this->errors = ''; TribeEventsQuery::init(); Tribe__Events__Backcompat::init(); Tribe__Events__Credits::init(); $this->registerPostType(); self::debug(sprintf(__('Initializing Tribe Events on %s', 'tribe-events-calendar'), date('M, jS \\a\\t h:m:s a'))); $this->maybeMigrateDatabase(); $this->maybeSetTECVersion(); }
/** * The Calendar View AJAX Handler. * * @return void * @since 3.0 */ function calendar_ajax_call() { if (isset($_POST["eventDate"]) && $_POST["eventDate"]) { TribeEventsQuery::init(); global $wp_query; // set the global query var for eventDisplay $wp_query->set('eventDisplay', 'month'); if (!empty($_REQUEST['eventDate'])) { $wp_query->set('eventDate', $_REQUEST['eventDate']); } if (isset($_POST['tribe_event_category'])) { $wp_query->set(TribeEvents::TAXONOMY, $_POST['tribe_event_category']); } if (class_exists('TribeEventsFilterView')) { TribeEventsFilterView::instance()->createFilters(null, true); } $wp_query->tribe_is_event_query = true; $this->setDisplay(); ob_start(); tribe_get_view('month/content'); $response = array('html' => ob_get_clean(), 'success' => true, 'view' => 'month'); apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); die; } }
/** * AJAX handler for the Map view */ function ajax_tribe_geosearch() { if (class_exists('TribeEventsFilterView')) { TribeEventsFilterView::instance()->createFilters(null, true); $this->setup_geoloc_filter_in_filters(); } $tribe_paged = !empty($_POST["tribe_paged"]) ? $_POST["tribe_paged"] : 1; TribeEventsQuery::init(); $defaults = array('post_type' => TribeEvents::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'paged' => $tribe_paged, 'post_status' => array('publish'), 'eventDisplay' => 'map'); $view_state = 'map'; /* if past view */ if (!empty($_POST['tribe_event_display']) && $_POST['tribe_event_display'] == 'past') { $view_state = 'past'; add_filter('tribe_events_pre_get_posts', array($this, 'set_past_events_query')); } $query = TribeEventsQuery::getEvents($defaults, true); if ($this->is_geoloc_query() && $query->found_posts > 0) { $lat = isset($_POST['tribe-bar-geoloc-lat']) ? $_POST['tribe-bar-geoloc-lat'] : 0; $lng = isset($_POST['tribe-bar-geoloc-lng']) ? $_POST['tribe-bar-geoloc-lng'] : 0; $this->order_posts_by_distance($query->posts, $lat, $lng); } $response = array('html' => '', 'markers' => array(), 'success' => true, 'tribe_paged' => $tribe_paged, 'max_pages' => $query->max_num_pages, 'total_count' => $query->found_posts, 'view' => $view_state); if ($query->found_posts > 0) { global $wp_query, $post; $data = $query->posts; $post = $query->posts[0]; $wp_query = $query; TribeEvents::instance()->setDisplay(); ob_start(); tribe_get_view('map/content'); $response['html'] .= ob_get_clean(); $response['markers'] = $this->generate_markers($data); } else { global $wp_query; $wp_query = $query; TribeEvents::instance()->setDisplay(); ob_start(); tribe_get_view('map/content'); $response['html'] .= ob_get_clean(); } apply_filters('tribe_events_ajax_response', $response); header('Content-type: application/json'); echo json_encode($response); exit; }
/** * Generates the iCal file * * @static * * @param int|null $post If you want the ical file for a single event */ public static function generate_ical_feed($post = null) { $tec = TribeEvents::instance(); $wp_timezone = get_option('timezone_string'); $events = ''; $blogHome = get_bloginfo('url'); $blogName = get_bloginfo('name'); $event_display = !empty($_REQUEST['tribe_display']) ? $_REQUEST['tribe_display'] : 'upcoming'; if ($event_display == 'list') { $event_display = 'upcoming'; } if ($post) { $events_posts = array(); $events_posts[] = $post; } else { TribeEventsQuery::init(); $events_query = TribeEventsQuery::getEvents(array('posts_per_page' => -1, 'eventDisplay' => $event_display), true); $events_posts = $events_query->posts; } foreach ($events_posts as $event_post) { $startDate = $event_post->EventStartDate; $endDate = $event_post->EventEndDate; // convert 2010-04-08 00:00:00 to 20100408T000000 or YYYYMMDDTHHMMSS $startDate = str_replace(array('-', ' ', ':'), array('', 'T', ''), $startDate); $endDate = str_replace(array('-', ' ', ':'), array('', 'T', ''), $endDate); if (get_post_meta($event_post->ID, '_EventAllDay', true) == 'yes') { $startDate = substr($startDate, 0, 8); $endDate = substr($endDate, 0, 8); // endDate bumped ahead one day to counter iCal's off-by-one error $endDateStamp = strtotime($endDate); $endDate = date('Ymd', $endDateStamp + 86400); $type = 'DATE'; } else { $type = 'DATE-TIME'; } $description = preg_replace("/[\n\t\r]/", ' ', strip_tags($event_post->post_content)); // add fields to iCal output $item = array(); $item[] = "DTSTART;VALUE={$type}:" . $startDate; $item[] = "DTEND;VALUE={$type}:" . $endDate; $item[] = 'DTSTAMP:' . date('Ymd\\THis', time()); $item[] = 'CREATED:' . str_replace(array('-', ' ', ':'), array('', 'T', ''), $event_post->post_date); $item[] = 'LAST-MODIFIED:' . str_replace(array('-', ' ', ':'), array('', 'T', ''), $event_post->post_modified); $item[] = 'UID:' . $event_post->ID . '-' . strtotime($startDate) . '-' . strtotime($endDate) . '@' . $blogHome; $item[] = 'SUMMARY:' . $event_post->post_title; $item[] = 'DESCRIPTION:' . str_replace(',', '\\,', $description); $item[] = 'URL:' . get_permalink($event_post->ID); // add location if available $location = $tec->fullAddressString($event_post->ID); if (!empty($location)) { $item[] = 'LOCATION:' . html_entity_decode($location, ENT_QUOTES); } // add geo coordinates if available if (class_exists('TribeEventsGeoLoc')) { $long = TribeEventsGeoLoc::instance()->get_lng_for_event($event_post->ID); $lat = TribeEventsGeoLoc::instance()->get_lat_for_event($event_post->ID); if (!empty($long) && !empty($lat)) { $item[] = sprintf('GEO:%s;%s', $long, $lat); } } // add categories if available $event_cats = (array) wp_get_object_terms($event_post->ID, TribeEvents::TAXONOMY, array('fields' => 'names')); if (!empty($event_cats)) { $item[] = 'CATEGORIES:' . html_entity_decode(join(',', $event_cats), ENT_QUOTES); } // add featured image if available if (has_post_thumbnail($event_post->ID)) { $thumbnail_id = get_post_thumbnail_id($event_post->ID); $thumbnail_url = wp_get_attachment_url($thumbnail_id); $thumbnail_mime_type = get_post_mime_type($thumbnail_id); $item[] = apply_filters('tribe_ical_feed_item_thumbnail', sprintf('ATTACH;FMTTYPE=%s:%s', $thumbnail_mime_type, $thumbnail_url), $event_post->ID); } // add organizer if available $organizer_email = tribe_get_organizer_email($event_post->ID); if ($organizer_email) { $organizer_name = tribe_get_organizer($event_post->ID); if ($organizer_name) { $item[] = sprintf('ORGANIZER;CN=%s:MAILTO:%s', $organizer_name, $organizer_email); } else { $item[] = sprintf('ORGANIZER:MAILTO:%s', $organizer_email); } } $item = apply_filters('tribe_ical_feed_item', $item, $event_post); $events .= "BEGIN:VEVENT\r\n" . implode("\r\n", $item) . "\r\nEND:VEVENT\r\n"; } header('Content-type: text/calendar; charset=UTF-8'); header('Content-Disposition: attachment; filename="iCal-TribeEvents.ics"'); $content = "BEGIN:VCALENDAR\r\n"; $content .= "VERSION:2.0\r\n"; $content .= 'PRODID:-//' . $blogName . ' - ECPv' . TribeEvents::VERSION . "//NONSGML v1.0//EN\r\n"; $content .= "CALSCALE:GREGORIAN\r\n"; $content .= "METHOD:PUBLISH\r\n"; $content .= 'X-WR-CALNAME:' . apply_filters('tribe_ical_feed_calname', $blogName) . "\r\n"; $content .= 'X-ORIGINAL-URL:' . $blogHome . "\r\n"; $content .= 'X-WR-CALDESC:Events for ' . $blogName . "\r\n"; if ($wp_timezone) { $content .= 'X-WR-TIMEZONE:' . $wp_timezone . "\r\n"; } $content = apply_filters('tribe_ical_properties', $content); $content .= $events; $content .= 'END:VCALENDAR'; echo $content; exit; }