Created
December 13, 2017 06:56
-
-
Save westcoastdigital/4be1642844dcf8a7ce4ecbdf6f4d2587 to your computer and use it in GitHub Desktop.
Adds a banner to the top of GP page that shows up for Christmas every year
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function jm_xmas_announcement() { | |
| $xmascta = '<div class="xmas-announcement" style="background:#e6092a;text-align:center;padding:10px;">'; | |
| $xmascta .= '<a href="' . get_page_link(350) . '" style="color:white;text-transform:uppercase;">'; | |
| $xmascta .= '<p style="margin-bottom:0;padding:10px;border:1px solid white;">Now Taking Christmas Orders</p>'; | |
| $xmascta .= '</a>'; | |
| $xmascta .= '</div>'; | |
| $now = time(); | |
| $year = date('Y'); | |
| $promo = strtotime("01 November $year"); | |
| $christmas = strtotime("25 December $year"); | |
| if ( is_front_page() && $now > $promo && $now < $christmas ) { | |
| echo $xmascta; | |
| } | |
| } | |
| add_action( 'generate_before_header', 'jm_xmas_announcement' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment