From 2322eb3e66a01181cb2d500178e1429c4c932cd8 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Wed, 30 Oct 2024 21:37:11 +0200 Subject: [PATCH] Extract front page content into a separate file, extract event times into a config file --- config-events.php | 16 ++++++++++ front-page-content.php | 70 ++++++++++++++++++++++++++++++++++++++++++ front-page.php | 57 +--------------------------------- 3 files changed, 87 insertions(+), 56 deletions(-) create mode 100644 config-events.php create mode 100644 front-page-content.php diff --git a/config-events.php b/config-events.php new file mode 100644 index 0000000..ca75ee5 --- /dev/null +++ b/config-events.php @@ -0,0 +1,16 @@ + [ + 'startTime' => '2024-11-02 09:45:00', + 'endTime' => '2024-11-03 18:15:00', + 'streams' => [[ + 'startTime' => '2024-11-02 09:45:00', + 'endTime' => '2024-11-02 19:00:00', + 'tracks' => ['hall-a', 'hall-b'], + ], [ + 'startTime' => '2024-11-03 09:45:00', + 'endTime' => '2024-11-03 18:15:00', + 'tracks' => ['hall-a', 'hall-b'], + ]], + ], +]; diff --git a/front-page-content.php b/front-page-content.php new file mode 100644 index 0000000..5ffbf71 --- /dev/null +++ b/front-page-content.php @@ -0,0 +1,70 @@ +diff($eventStart); +$isBeforeEvent = $eventStartInterval instanceof DateInterval && $eventStartInterval->invert === 0; + +$eventEnd = new DateTimeImmutable($eventsConfig[$blog_slug]['eventEnd'] . ' Europe/Sofia'); +$eventEndInterval = $now->diff($eventEnd); +$isAfterEvent = $eventEndInterval instanceof DateInterval && $eventEndInterval->invert === 1; + +if ($isBeforeEvent) { +?> + +

+
+ + + + + + + + + + + + + + +
format('%a'); ?>format('%H'); ?>format('%I'); ?>
+ +
+ + + '2024-11-02 10:00:00', -]; - -$blog_slug = get_blog_slug(); - -if (array_key_exists($blog_slug, $eventStartTimes)) { - $now = new DateTimeImmutable('now'); - $eventStart = new DateTimeImmutable($eventStartTimes[$blog_slug] . ' Europe/Sofia'); - $interval = $now->diff($eventStart); -} - -if ($interval instanceof DateInterval && $interval->invert === 0) { -?> - -

-
- - - - - - - - - - - - - - -
format('%a'); ?>format('%H'); ?>format('%I'); ?>
- -
-