-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage-events.php
More file actions
117 lines (104 loc) · 3.84 KB
/
Copy pathpage-events.php
File metadata and controls
117 lines (104 loc) · 3.84 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php /**
* Template Name: Events page
*/ ?>
<?php get_header(); ?>
<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
<header class="page-thumb page-thumb--<?php the_field('palette_color') ?>">
<?php if ( has_post_thumbnail() ) : ?>
<?php the_post_thumbnail('post-thumbnail',
array( 'class' => 'page-thumb__img')
); ?>
<?php else: ?>
<div class="page-thumb__spacer"></div>
<?php endif; ?>
</header>
<main class="page <?php the_field('palette_color') ?>" id="site-content">
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php
$add_calendar_url = sprintf("https://calendar.google.com/calendar/u/0/r?cid=%s", CALENDAR_ID);
$ics_calendar_url = sprintf("https://calendar.google.com/calendar/ical/%s/public/basic.ics", urlencode(CALENDAR_ID));
?>
<aside class="calendar-links">
<a class="referral referral--heavy referral--arrowed" href="<?php echo $add_calendar_url; ?>"
target="_blank">
Voeg deze agenda toe aan je <strong>Google Calendar</strong></a>
<label class="text-label text-label--no-margin" for="ics-url">Of gebruik deze ICS-url:
<input type="text" value="<?php echo $ics_calendar_url; ?>" disabled>
</label>
</aside>
<?php
include('inc/get-events.php');
$response = getEvents();
$time_format = get_option( 'time_format' );
$date_format = get_option( 'date_format' );
foreach ($response['events'] as $key => $event) { ?>
<article class="event">
<?php
$default_events = [
'zomerkamp',
'poffertjes',
'open dag',
'sinterklaas',
'grote clubactie',
'klussendag'
];
$event_link = false;
foreach ($default_events as $slug) {
if ( strpos( strtolower( $event['summary'] ), $slug) === 0 ) {
$event_post = get_page_by_path($slug, OBJECT, 'activiteiten');
$event_link = get_post_permalink($event_post);
print_r(get_the_post_thumbnail($event_post));
}
}
?>
<p class="event__moment">
<?php
$compare_start = clone $event['start'];
$compare_end = clone $event['end'];
if ($event['has_time']) {
$format = sprintf("%s %s", $date_format, $time_format);
} else {
$format = sprintf("%s", $date_format);
}
if (getNightsBetween($compare_start, $compare_end) > 0) {
$end_fix = $event['end']->sub(new DateInterval('P1D'));
echo sprintf("🗓️ <strong>%s</strong> – %s",
wp_date($format, $event['start']->format('U')),
wp_date($format, $end_fix->format('U')));
} else {
echo sprintf("📅 <strong>%s</strong> – %s",
wp_date($format, $event['start']->format('U')),
wp_date($time_format, $event['end']->format('U')));
}
?>
</p>
<h2 class="event__summary">
<?php echo $event['summary']; ?>
</h2>
<?php if (!empty($event['location'])) { ?>
<p class="event__location">
📍 <?php echo $event['location']; ?>
</p>
<?php } ?>
<?php if (!empty($event['description'])) { ?>
<p class="event__description">
<?php echo $event['description']; ?>
</p>
<?php } ?>
<?php if ($event_link) { ?>
<p class="event__link">
<a href="<?php echo $event_link; ?>">
Algemene pagina over <?php echo $event['summary']; ?>
</a>
</p>
<?php } ?>
</article>
<?php } ?>
</main>
<?php endwhile; else: ?>
<main>
<p>Sorry, deze pagina lijkt niet te bestaan.</p>
</main>
<?php endif; ?>
<?php get_footer(); ?>