Skip to content

Instantly share code, notes, and snippets.

@ramseyp
Last active April 9, 2020 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramseyp/538d79d1a5a5f9df592d224a6e489ffb to your computer and use it in GitHub Desktop.
Save ramseyp/538d79d1a5a5f9df592d224a6e489ffb to your computer and use it in GitHub Desktop.
WP snippets for CSS Naked Day
<?php
function bk_is_naked_day($d) {
$start = date('U', mktime(-12, 0, 0, 04, $d, date('Y')));
$end = date('U', mktime(36, 0, 0, 04, $d, date('Y')));
$z = date('Z') * -1;
$now = time() + $z;
if ( $now >= $start && $now <= $end ) {
return true;
}
return false;
}
function bk_remove_all_css(){
global $wp_styles;
if ( bk_is_naked_day( 9 ) ) {
$wp_styles->queue = array();
}
}
add_action( 'wp_print_styles', 'bk_remove_all_css', 99 );
function bk_announce_naked_day() {
if ( bk_is_naked_day( 9 ) ) {
echo "<p><i>🔥 Why does my website look so <strong>naked</strong>? April 9th is <a href='https://css-naked-day.github.io/'>CSS naked day</a>. I'm participating to help promote web standards, including the proper use of HTML, semantic markup and more. I'm also using it as an opportunity to find out where I can improve the HTML on the site.</i></p>";
}
}
add_action( 'wp_body_open', 'bk_announce_naked_day' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment