-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeed_ics.php
More file actions
72 lines (48 loc) · 1.61 KB
/
feed_ics.php
File metadata and controls
72 lines (48 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
$posts = get_posts( array(
'post_type' => 'workshop',
'posts_per_page' => -1
));
usort($posts, function($a, $b) {
$start_date_a = get_post_meta($a->ID, 'workshop_start', true);
$start_date_b = get_post_meta($b->ID, 'workshop_start', true);
if ($start_date_a->format('Y-m-d') > $start_date_b->format('Y-m-d')) {
return 1;
}
if ($start_date_a->format('Y-m-d') < $start_date_b->format('Y-m-d')) {
return -1;
}
return 0;
});
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=calender-makerspace.ics");
header('Content-type: text/calendar; charset=utf-8');
header("Pragma: 0");
header("Expires: 0");
// print_r($posts);
const DT_FORMAT = 'Ymd\THis';
?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//bobbin v0.1//NONSGML iCal Writer//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
<?php
// var_dump( $posts);
?>
<?php foreach ( $posts as $post) : ?>
BEGIN:VEVENT
DTSTART:<?php echo get_post_meta($post->ID, 'workshop_start', true)->format(DT_FORMAT); ?>
DTEND:<?php echo get_post_meta($post->ID, 'workshop_end', true)->format(DT_FORMAT); ?>
UID:<?php echo get_the_date('YmdHis', $post->ID) ?>@makerspace.experimenta.science
CREATED:<?php echo get_the_date(DT_FORMAT, $post->ID) ?>
DESCRIPTION:<?php echo htmlspecialchars_decode ( get_the_excerpt($post->ID) ) ?>
SUMMARY:<?php echo htmlspecialchars_decode ( get_the_title($post->ID) ) ?>
LAST-MODIFIED:<?php echo get_the_date(DT_FORMAT, $post->ID) ?>
SEQUENCE:0
STATUS:CONFIRMED
TRANSP:OPAQUE
LOCATION: Maker Space Experimenta
END:VEVENT
<?php endforeach; ?>
END:VCALENDAR