PluginProbe
Event Post / 5.6
Event Post v5.6
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
event-post / inc / export / ics.php

ics.php in Event Post 5.6, at inc/export/ics.php

67 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(isset($event->post_title) && isset($event->time_start) && isset($event->time_end) && isset($event->post_excerpt) && isset($event->address) && isset($event->permalink)){
3 $timezone_string = get_option('timezone_string');
4 $gmt = $this->get_gmt_offset();
5 $allday = ($post->time_start && $post->time_end && date('H:i:s', $post->time_start) == '00:00:00' && date('H:i:s', $post->time_end) == '00:00:00');
6 $date_start = date("Ymd", $event->time_start) . ($allday ? '' : 'T' . date("His", $event->time_start));
7 $date_end = date("Ymd", $event->time_end) . ($allday ? '' : 'T' . date("His", $event->time_end));
8 header("content-type:text/".(isset($mime)?$mime:'calendar'));
9 header("Pragma: public");
10 header("Expires: 0");
11 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
12 header("Cache-Control: public");
13 header("Content-Disposition: attachment; filename=".$event->permalink.'.'.(isset($format)?$format:'ics').';' );
14
15 $timezone_string = $_GET['tz'];
16
17 $separator = "\n";
18
19 $props = array();
20
21 // General
22 $props[] = 'BEGIN:VCALENDAR';
23 $props[] = 'PRODID://WordPress//Event-Post V'. file_get_contents(('../VERSION')).'//EN';
24 $props[] = 'VERSION:2.0';
25
26 // Timezone
27 if(!empty($timezone_string)){
28 array_push($props,
29 'BEGIN:VTIMEZONE',
30 'TZID:'.$timezone_string,
31 'BEGIN:DAYLIGHT',
32 'TZOFFSETFROM:+0100',
33 'TZOFFSETTO:'.($gmt).'00',
34 //'TZNAME:CEST',
35 'DTSTART:19700329T020000',
36 'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=3',
37 'END:DAYLIGHT',
38 'BEGIN:STANDARD',
39 'TZOFFSETFROM:'.($gmt).'00',
40 'TZOFFSETTO:+0100',
41 'TZNAME:CET',
42 'DTSTART:19701025T030000',
43 'RRULE:FREQ=YEARLY;BYDAY=-1SU;BYMONTH=10',
44 'END:STANDARD',
45 'END:VTIMEZONE'
46 );
47 }
48
49 // Event
50 array_push($props,
51 'BEGIN:VEVENT',
52 'SUMMARY:'.stripslashes($event->post_title),
53 'UID:'.$event->permalink,
54 'LOCATION:'.stripslashes($event->address),
55 'DTSTAMP:'.$date_start.(!empty($timezone_string)?'':'Z'),
56 'DTSTART'.(!empty($timezone_string)?';TZID='.$timezone_string:'').':'.$date_start.(!empty($timezone_string)?'':'Z'),
57 'DTEND'.(!empty($timezone_string)?';TZID='.$timezone_string:'').':'.$date_end.(!empty($timezone_string)?'':'Z'),
58 'DESCRIPTION:'.wordwrap($event->post_excerpt),
59 'END:VEVENT'
60 );
61
62 // End
63 $props[] = 'END:VCALENDAR';
64
65 echo implode($separator, $props);
66 }
67