function export_events_ics() { global $eventon; if (!wp_verify_nonce($_REQUEST['nonce'], 'eventon_download_events')) { die('Nonce Security Failed.'); } $events = $eventon->evo_generator->get_all_event_data(); if (!empty($events)) { $taxopt = get_option("evo_tax_meta"); // taxonomy options values; $slug = 'eventon_events'; header("Content-Type: text/Calendar; charset=utf-8"); header("Content-Disposition: inline; filename={$slug}.ics"); echo "BEGIN:VCALENDAR\n"; echo "VERSION:2.0\n"; echo "PRODID:-//eventon.com NONSGML v1.0//EN\n"; echo "CALSCALE:GREGORIAN\n"; echo "METHOD:PUBLISH\n"; foreach ($events as $event_id => $event) { $location = $summary = ''; if (!empty($event['details'])) { $summary = wp_trim_words($event['details'], 50, '[..]'); } // location $Locterms = wp_get_object_terms($event_id, 'event_location'); $location_name = $locationAddress = ''; if ($Locterms && !is_wp_error($Locterms)) { $location_name = $Locterms[0]->name; $termMeta = evo_get_term_meta('event_location', $Locterms[0]->term_id, $taxopt, true); $locationAddress = !empty($termMeta['location_address']) ? $termMeta['location_address'] : (!empty($event['location_address']) ? $event['location_address'] : ''); } $location = (!empty($location_name) ? $location_name : '') . ' ' . (!empty($locationAddress) ? $locationAddress : ''); $uid = uniqid(); echo "BEGIN:VEVENT\n"; echo "UID:{$uid}\n"; // required by Outlok echo "DTSTAMP:" . date_i18n('Ymd') . 'T' . date_i18n('His') . "\n"; // required by Outlook echo "DTSTART:" . evo_get_adjusted_utc($event['start']) . "\n"; echo "DTEND:" . evo_get_adjusted_utc($event['end']) . "\n"; if (!empty($location)) { echo "LOCATION:" . $this->esc_ical_text($location) . "\n"; } echo "SUMMARY:" . htmlspecialchars_decode($event['name']) . "\n"; if (!empty($summary)) { echo "DESCRIPTION: " . $this->esc_ical_text($summary) . "\n"; } echo "END:VEVENT\n"; // repeating instances if (!empty($event['repeats']) && is_array($event['repeats'])) { foreach ($event['repeats'] as $interval => $repeats) { if ($interval == 0) { continue; } $uid = uniqid(); echo "BEGIN:VEVENT\n"; echo "UID:{$uid}\n"; // required by Outlok echo "DTSTAMP:" . date_i18n('Ymd') . 'T' . date_i18n('His') . "\n"; // required by Outlook echo "DTSTART:" . evo_get_adjusted_utc($repeats[0]) . "\n"; echo "DTEND:" . evo_get_adjusted_utc($repeats[1]) . "\n"; if (!empty($location)) { echo "LOCATION:" . $this->esc_ical_text($location) . "\n"; } echo "SUMMARY:" . htmlspecialchars_decode($event['name']) . "\n"; if (!empty($summary)) { echo "DESCRIPTION: " . $this->esc_ical_text($summary) . "\n"; } echo "END:VEVENT\n"; } } } echo "END:VCALENDAR"; } }
function eventon_get_addgoogle_cal($object) { $location = !empty($object->evals['evcal_location']) ? urlencode($object->evals['evcal_location'][0]) : ''; $start = evo_get_adjusted_utc($object->estart); $end = evo_get_adjusted_utc($object->eend); $title = urlencode($object->etitle); return 'http://www.google.com/calendar/event?action=TEMPLATE&text=' . $title . '&dates=' . $start . '/' . $end . '&details=' . $title . '&location=' . $location; }
function eventon_ics_download() { $event_id = (int) $_GET['event_id']; $sunix = (int) $_GET['sunix']; $eunix = (int) $_GET['eunix']; //error_reporting(E_ALL); //ini_set('display_errors', '1'); //$the_event = get_post($event_id); $ev_vals = get_post_custom($event_id); $event_start_unix = $sunix; $event_end_unix = !empty($eunix) ? $eunix : $sunix; $name = $summary = get_the_title($event_id); // summary for ICS file $event = get_post($event_id); $content = !empty($event->post_content) ? $event->post_content : ''; if (!empty($content)) { $content = strip_tags($content); $content = str_replace(']]>', ']]>', $content); $summary = wp_trim_words($content, 50, '[..]'); //$summary = substr($content, 0, 500).' [..]'; } $location = !empty($ev_vals['evcal_location']) ? $ev_vals['evcal_location'][0] : ''; $start = evo_get_adjusted_utc($event_start_unix); $end = evo_get_adjusted_utc($event_end_unix); $uid = uniqid(); //$description = $the_event->post_content; ob_clean(); //$slug = strtolower(str_replace(array(' ', "'", '.'), array('_', '', ''), $name)); $slug = $event->post_name; header("Content-Type: text/Calendar; charset=utf-8"); header("Content-Disposition: inline; filename={$slug}.ics"); echo "BEGIN:VCALENDAR\n"; echo "VERSION:2.0\n"; echo "PRODID:-//eventon.com NONSGML v1.0//EN\n"; //echo "METHOD:REQUEST\n"; // requied by Outlook echo "BEGIN:VEVENT\n"; echo "UID:{$uid}\n"; // required by Outlok echo "DTSTAMP:" . date_i18n('Ymd') . 'T' . date_i18n('His') . "\n"; // required by Outlook echo "DTSTART:{$start}\n"; echo "DTEND:{$end}\n"; echo "LOCATION:{$location}\n"; echo "SUMMARY:{$name}\n"; echo "DESCRIPTION: {$summary}\n"; echo "END:VEVENT\n"; echo "END:VCALENDAR"; exit; }