Make WordPress Core


Ignore:
Timestamp:
01/15/2015 11:09:07 PM (7 years ago)
Author:
lancewillett
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r31182 r31184  
    195195
    196196/**
     197 * JavaScript Detection.
     198 *
     199 * Adds a `js` class to the root `<html>` element when JavaScript is detected.
     200 *
     201 * @since Twenty Fifteen 1.1
     202 */
     203function twentyfifteen_javascript_detection() {
     204    echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n";
     205}
     206add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 );
     207
     208/**
    197209 * Enqueue scripts and styles.
    198210 *
Note: See TracChangeset for help on using the changeset viewer.