function get_icalendar_events()
 {
     require 'class.rhc_icalendar.php';
     $_REQUEST['start'] = 0;
     $_REQUEST['end'] = mktime(0, 0, 0, 0, 0, date('Y') + 20);
     $ical = new events_to_vcalendar($this->_get_calendar_items());
     die($ical->get_vcalendar());
 }
 function get_icalendar_events()
 {
     global $rhc_plugin;
     require 'class.rhc_icalendar.php';
     $_REQUEST['start'] = 0;
     $_REQUEST['end'] = mktime(0, 0, 0, 0, 0, date('Y') + 20);
     $post_ID = isset($_REQUEST['ID']) && intval($_REQUEST['ID']) > 0 ? intval($_REQUEST['ID']) : false;
     if ('1' == $rhc_plugin->get_option('disable_icalendar_utc', '', true)) {
         $gmt_offset = false;
     } else {
         $gmt_offset = get_option('gmt_offset');
     }
     $tzid = apply_filters('rhc_tzid', '');
     $vtimezone = apply_filters('rhc_vtimezone', '');
     $ical = new events_to_vcalendar($this->_get_calendar_items($post_ID), $gmt_offset, $tzid, $vtimezone);
     $output = trim($ical->get_vcalendar());
     if (isset($_REQUEST['ics'])) {
         if ($post_ID > 0) {
             $filename = "event_" . $post_ID . ".ics";
         } else {
             $filename = "events.ics";
         }
         header("Cache-Control: public");
         header("Content-Description: File Transfer");
         header("Content-Length: " . strlen($output) . ";");
         header('Content-Type: text/calendar; charset=utf-8');
         //change mainly for google.
         header("Content-Disposition: attachment; filename={$filename}");
         //header("Content-Type: application/octet-stream; ");
         header("Content-Transfer-Encoding: binary");
     } else {
         $this->handle_get_icalendar_events_header();
     }
     die($output);
 }