-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfront-page-content.php
99 lines (83 loc) · 2.54 KB
/
front-page-content.php
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
<?php
if (!function_exists('get_blog_slug')) {
exit;
}
require __DIR__ . '/config-events.php';
$blog_slug = get_blog_slug();
if (!array_key_exists($blog_slug, $eventsConfig)) {
return;
}
$now = new DateTimeImmutable('now');
function interval_to_now(string $dateTimeStr) {
global $now;
return $now->diff(new DateTimeImmutable($dateTimeStr . ' Europe/Sofia'));
}
function is_before_interval(DateInterval $interval) {
return $interval->invert === 0;
}
function is_after_interval(DateInterval $interval) {
return $interval->invert === 1;
}
$eventStartInterval = interval_to_now($eventsConfig[$blog_slug]['startTime']);
$isBeforeEvent = is_before_interval($eventStartInterval);
$eventEndInterval = interval_to_now($eventsConfig[$blog_slug]['endTime']);
$isAfterEvent = is_after_interval($eventEndInterval);
$activeStreams = array_filter($eventsConfig[$blog_slug]['streams'], function($stream) {
$streamStartInterval = interval_to_now($stream['startTime']);
$streamEndInterval = interval_to_now($stream['endTime']);
return is_after_interval($streamStartInterval) && is_before_interval($streamEndInterval);
});
$activeStream = reset($activeStreams);
$noCurrentStreams = !$isBeforeEvent && !$isAfterEvent && $activeStream === false;
if ($isBeforeEvent) {
?>
<div class="countdown">
<?php e_('countdown_text_before'); ?>
<table>
<tbody>
<tr class="digits">
<td><?php echo $eventStartInterval->format('%a'); ?></td>
<td><?php echo $eventStartInterval->format('%H'); ?></td>
<td><?php echo $eventStartInterval->format('%I'); ?></td>
</tr>
<tr class="units">
<td><?php e_('countdown_days'); ?></td>
<td><?php e_('countdown_hours'); ?></td>
<td><?php e_('countdown_minutes'); ?></td>
</tr>
</tbody>
</table>
<?php e_('countdown_text_after'); ?>
</div>
<?php
}
if ($activeStream) {
?>
<div class="stream_players_wrapper">
<?php
foreach ($activeStream['tracks'] as $track) {
?>
<div>
<h3><?php e_($track); ?></h3>
<?php echo do_shortcode('[stream-player track="' . $track . '"]'); ?>
</div>
<?php
}
?>
</div>
<?php
}
if ($noCurrentStreams) {
?>
<div class="no_current_streams">
<?php e_('no_current_streams'); ?>
</div>
<?php
}
if ($isAfterEvent) {
?>
<div class="after_event">
<?php e_('after_event'); ?>
</div>
<?php
}