PluginProbe
Event Post / 6.0.1
Event Post v6.0.1
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 6.0.1, at inc/export/ics.php

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