PluginProbe
Event Post / 5.12.0
Event Post v5.12.0
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.12.0, at inc/export/ics.php

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