get_var('SELECT event_id FROM '.EM_EVENTS_TABLE." WHERE event_slug='".get_query_var(EM_POST_TYPE_EVENT)."' AND event_status=1 LIMIT 1"); if( !empty($event_id) ){ global $EM_Event; $EM_Event = em_get_event($event_id); ob_start(); em_locate_template('templates/ical-event.php', true); echo preg_replace("/([^\r])\n/", "$1\r\n", ob_get_clean()); exit(); } } } add_action ( 'parse_query', 'em_ical_event' ); function em_ical_events(){ ob_start(); em_locate_template('templates/ical.php', true); return preg_replace("/([^\r])\n/", "$1\r\n", ob_get_clean());//get the contents to output and clean crlf issues } function em_update_ical($result){ update_option('dbem_regenerate_ical',true); return $result; } add_filter('em_event_save','em_update_ical', 1, 1); ?>