Created
February 28, 2017 10:29
-
-
Save nickdavis/73d91d674b843b77a1cd0a21f9c0353a to your computer and use it in GitHub Desktop.
Add 'no-js' class to <html> tag in WordPress in order to work with Modernizr
This file contains 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
<?php | |
add_filter( 'language_attributes', 'add_no_js_class_to_html_tag', 10, 2 ); | |
/** | |
* Add 'no-js' class to <html> tag in order to work with Modernizr. | |
* | |
* (Modernizr will change class to 'js' if JavaScript is supported). | |
* | |
* @since 1.0.0 | |
* | |
* @param string $output A space-separated list of language attributes. | |
* @param string $doctype The type of html document (xhtml|html). | |
* | |
* @return string $output A space-separated list of language attributes. | |
*/ | |
function add_no_js_class_to_html_tag( $output, $doctype ) { | |
if ( 'html' !== $doctype ) { | |
return $output; | |
} | |
$output .= ' class="no-js"'; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!