Skip to content

Commit 056826c

Browse files
committed
Check if we have events to display
1 parent e17c691 commit 056826c

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

ics-shortcode.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,26 @@ function ICSEvents($atts)
4848
}
4949
}
5050
$html = '';
51-
foreach ($eventsToDisplay as $event) {
52-
$timestamp = $ical->iCalDateToUnixTimestamp($event['DTSTART']);
53-
$html .= '<ul class="next-date">
54-
<li><time datetime="'.strftime('%F', $timestamp).'">
55-
<span>'.strftime('%e', $timestamp).'</span>
56-
<span>'.strftime('%b', $timestamp).'</span></time></li>
57-
<li>'.$event['SUMMARY'].'</li>';
58-
if (!empty($event['LOCATION'])) {
59-
$html .= '<li>'.$event['LOCATION'].'</li>';
51+
if (empty($eventsToDisplay)) {
52+
if (isset($atts['noeventsmsg']) ){
53+
$html .= $atts['noeventsmsg'];
6054
}
61-
if (strlen($event['DTSTART']) > 8) {
62-
$html .= '<li>'.strftime('%Hh%M', $timestamp).'</li>';
55+
} else {
56+
foreach ($eventsToDisplay as $event) {
57+
$timestamp = $ical->iCalDateToUnixTimestamp($event['DTSTART']);
58+
$html .= '<ul class="next-date">
59+
<li><time datetime="'.strftime('%F', $timestamp).'">
60+
<span>'.strftime('%e', $timestamp).'</span>
61+
<span>'.strftime('%b', $timestamp).'</span></time></li>
62+
<li>'.$event['SUMMARY'].'</li>';
63+
if (!empty($event['LOCATION'])) {
64+
$html .= '<li>'.$event['LOCATION'].'</li>';
65+
}
66+
if (strlen($event['DTSTART']) > 8) {
67+
$html .= '<li>'.strftime('%Hh%M', $timestamp).'</li>';
68+
}
69+
$html .= '</ul>';
6370
}
64-
$html .= '</ul>';
6571
}
6672
return $html;
6773

0 commit comments

Comments
 (0)