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.
Built from https://develop.svn.wordpress.org/trunk@31184


git-svn-id: http://core.svn.wordpress.org/trunk@31165 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2015-01-15 23:10:22 +00:00
parent 4d00172987
commit 7be12f7d8d
3 changed files with 13 additions and 2 deletions

View File

@ -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.
*

View File

@ -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>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.2-alpha-31183';
$wp_version = '4.2-alpha-31184';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.