CSS Naked Day

I learned from Dries, founder of Drupal, that today is “CSS Naked Day” which encourages site owners to disable all CSS. You can read more about it on the day’s site.

Here’s a quick and dirty snippet to add to a WordPress site to enable it.

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' );

Comments

One response

  1. Dries Buytaert

    That is a goal of Naked CSS day: to discover opportunities for improvement. 👍

Leave a Reply

Your email address will not be published. Required fields are marked *

To respond on your own website, enter the URL of your response which should contain a link to this post’s permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post’s URL again. (Find out more about Webmentions.)