Twenty Fifteen: move js
and no-js
class name functionality out of header template and into a wp_head
hook in functions.php file so that the JavaScript functionality isn't hard-coded into a template file.
Fixes #30770, props chipbennett, valendesigns, and peterwilsoncc. git-svn-id: https://develop.svn.wordpress.org/trunk@31184 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f09026e439
commit
ff779e2d0e
@ -193,6 +193,18 @@ function twentyfifteen_fonts_url() {
|
||||
}
|
||||
endif;
|
||||
|
||||
/**
|
||||
* JavaScript Detection.
|
||||
*
|
||||
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
|
||||
*
|
||||
* @since Twenty Fifteen 1.1
|
||||
*/
|
||||
function twentyfifteen_javascript_detection() {
|
||||
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
|
||||
}
|
||||
add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 );
|
||||
|
||||
/**
|
||||
* Enqueue scripts and styles.
|
||||
*
|
||||
|
@ -18,7 +18,6 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script src="<?php echo esc_url( get_template_directory_uri() ); ?>/js/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script>(function(){document.documentElement.className='js'})();</script>
|
||||
<?php wp_head(); ?>
|
||||
</head>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user