Update the slideshow page to check for dates and show time ribbon
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 7 Apr 2016 14:23:31 +0000 (10:23 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 7 Apr 2016 14:23:31 +0000 (10:23 -0400)
Time ribbon is is the slideshow partial.
Checking for current time use time()

parts/slide-show.php

index c2a18e7..af5b750 100644 (file)
@@ -3,13 +3,32 @@
     <?php get_template_part('parts/top-bar');?>
     <div id="slide-shadow">
     <?php
-        echo do_shortcode("[metaslider id=13]");
+        echo do_shortcode("[metaslider id=4]");
         echo do_shortcode("[metaslider id=19]");
     ?>
     </div>
     <div style="text-align: center">
-<?php $today = mktime();?>
-        <img id="open" class="small-centered medium-uncentered" src="<?php echo get_template_directory_uri(); ?>/assets/time-ribbon_closed.png">
+<?php
+$today     = time();
+// for testing the dates to test use mktime() for the current time use time()
+$today     = mktime(0, 0, 0, 11, 2, 2016);
+$start9to8 = mktime( 0, 0, 0, 5, 21, date('Y'));
+$end9to8   = mktime( 0, 0, 0, 9, 30, date('Y'));
+$start9to7 = mktime( 0, 0, 0, 10, 1, date('Y'));
+$end9to7   = mktime( 0, 0, 0, 11, 1, date('Y'));
+// check the date
+// if time is between May 21st and September 30 then hours should be 9am to 8pm
+// if time is between Oct 1st and Nov 1 then hours should be 9am to 7pm
+// else show the closed ribbon
+if ( $today >= $start9to8 && $today <= $end9to8 ) {
+    $ribbon = 'open-today.png';
+} else if ( $today >= $start9to7 && $today <= $end9to7 ) {
+    $ribbon = 'time-ribbon_9-7.png';
+} else {
+    $ribbon = 'time-ribbon_closed.png';
+}
+?>
+    <img id="open" class="small-centered medium-uncentered" src="<?php echo get_template_directory_uri(); ?>/assets/<?php echo $ribbon;?>">
     </div>
 
 </div>