Last active
September 24, 2017 19:39
-
-
Save patric-boehner/551ca5e144ea09bd54cf98c2e05a84f2 to your computer and use it in GitHub Desktop.
Adds a small inline script to append `js` class to body tag if JavaScript is enabled in Genesis theme
This file contains hidden or 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 | |
| /** | |
| * Script sample comes from WP SiteCare's carelib | |
| * https://github.com/wpsitecare/carelib | |
| * | |
| * A simplified version of Gary Jones Genesis JS | |
| * https://github.com/GaryJones/genesis-js-no-js/ | |
| * | |
| * This produces what the Genesis Sample Theme does in the | |
| * 'responsive-menu.js' but moves it to a small inline script that | |
| * is added after the opening <body> tag. | |
| * Unlike Gary's sample i've skipped adding a no-js body tag as the | |
| * Genesis Sample Theme does not include it and all styles tied to a | |
| * JS interaction are styled with .js | |
| * | |
| * If you use this action, you will need to go into 'responsive-menu.js' | |
| * and remove line 6 '$( 'body' ).addClass( 'js' );'. | |
| * | |
| */ | |
| // Add JS after opening <body> to append .js to body tag in Genesis | |
| add_action( 'genesis_before', 'pb_add_js_body_class' ); | |
| function pb_add_js_body_class() { | |
| echo '<script type="text/javascript">document.body.classList.add("js");</script>' . "\n"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment