-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
156 additions
and
87 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Genesis js / no-js Changelog | ||
|
||
## 2.0.0 (2014-08-23) | ||
|
||
* Refactor class into a new file. Stops using half-implemented Singleton pattern. | ||
* Update documentation. | ||
* Add GitHub Updater support. | ||
|
||
## 1.0.1 (2011-06-02) | ||
|
||
* Improved plugin so script is hooked in with priority 1 - avoids a theme placing anything before the script (props [Josh Stauffer](http://twitter.com/joshstauffer)) | ||
|
||
## 1.0.0 (2011-05-24) | ||
|
||
* Initial release. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Genesis js / no-js | ||
|
||
Make front-end styling easier for child themes on the Genesis Framework based on whether JavaScript is enabled or not. | ||
|
||
## Description | ||
|
||
If you look at the source of a WordPress back-end page, you'll see it has a body class of `no-js`. Immediately after the opening `body` tag is a small script which replaces `no-js` with `js` (you can see the amended class with Firebug / Inspector). | ||
|
||
WordPress uses this to apply different styles to the same elements, depending on whether JavaScript is present or not. | ||
|
||
This plugin recreates the same effect, but for the front-end of <a href="http://genesis-theme-framework.com/">Genesis Framework</a> child themes. It uses the `genesis_before` hook supplied by Genesis, so it won't work for other themes. | ||
|
||
The script is fairly small so does not block rendering of other content for any noticeable length of time. | ||
|
||
Putting the script at the top also reduces a flash of incorrectly styled content, as the page does not load with `no-js` styles, then switch to `js` once everything has finished loading. | ||
|
||
## Installation | ||
|
||
Once this plugin is installed and activated, then it will work automatically. There are no options, and nothing to set-up. | ||
|
||
### Upload | ||
|
||
1. Download the latest tagged archive (choose the "zip" option). | ||
2. Go to the __Plugins -> Add New__ screen and click the __Upload__ tab. | ||
3. Upload the zipped archive directly. | ||
4. Go to the Plugins screen and click __Activate__. | ||
|
||
### Manual | ||
|
||
1. Download the latest tagged archive (choose the "zip" option). | ||
2. Unzip the archive. | ||
3. Copy the folder to your `/wp-content/plugins/` directory. | ||
4. Go to the Plugins screen and click __Activate__. | ||
|
||
Check out the Codex for more information about [installing plugins manually](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation). | ||
|
||
### Git | ||
|
||
Using git, browse to your `/wp-content/plugins/` directory and clone this repository: | ||
|
||
`git clone git@github.com:GaryJones/genesis-js-no-js.git` | ||
|
||
Then go to your Plugins screen and click __Activate__. | ||
|
||
## Updates | ||
|
||
This plugin supports the [GitHub Updater](https://github.com/afragen/github-updater) plugin, so if you install that, this plugin becomes automatically updateable direct from GitHub. | ||
|
||
## Credits | ||
|
||
Built by [Gary Jones](https://twitter.com/GaryJ) | ||
Copyright 2011 [Gamajo Tech](http://gamajo.com/) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/** | ||
* Genesis Header Nav | ||
* | ||
* @package GenesisJsNoJs | ||
* @author Gary Jones | ||
* @link https://github.com/GaryJones/genesis-header-nav | ||
* @copyright 2011 Gary Jones, Gamajo Tech | ||
* @license GPL-2.0+ | ||
*/ | ||
|
||
/** | ||
* Plugin class. | ||
* | ||
* @package GenesisJsNoJs | ||
* @author Gary Jones | ||
*/ | ||
class Genesis_Js_No_Js { | ||
|
||
/** | ||
* Add action and filter. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function run() { | ||
add_filter( 'body_class', array( $this, 'body_class' ) ); | ||
add_action( 'genesis_before', array( $this, 'script' ), 1 ); | ||
} | ||
|
||
/** | ||
* Add 'no-js' class to the body class values. | ||
* | ||
* @since 1.0.0 | ||
* | ||
* @param array $classes Existing classes | ||
* @return array | ||
*/ | ||
public function body_class( $classes ) { | ||
$classes[] = 'no-js'; | ||
return $classes; | ||
} | ||
|
||
/** | ||
* Echo out the script that changes 'no-js' class to 'js'. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public function script() { | ||
?> | ||
<script type="text/javascript"> | ||
//<![CDATA[ | ||
(function(){ | ||
var c = document.body.className; | ||
c = c.replace(/no-js/, 'js'); | ||
document.body.className = c; | ||
})(); | ||
//]]> | ||
</script> | ||
<?php | ||
} | ||
} |
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