Skip to content

Commit

Permalink
Add filter for nav priority within header.
Browse files Browse the repository at this point in the history
In 1.0.0, the default priority for adding the nav to genesis_header hook was 8. This has now changed to 12, but this can be changed  with the genesis_header_nav_priority filter.
  • Loading branch information
GaryJones committed Aug 30, 2013
1 parent 12f5dc9 commit 13a299b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ Then go to your Plugins screen and click __Activate__.

Once activated, head to Appearance -> Menus. Create a menu as usual, and assign it to the Header menu location.

## Customising

### CSS

The plugin should work with all Genesis child themes, though you may need to add styles to position the output in the traditional place of top right, e.g.:

~~~css
Expand All @@ -67,6 +71,26 @@ The plugin should work with all Genesis child themes, though you may need to add

Adjust the width as needed to allow enough space for your title area and menu items.

### Priority

The plugin includes a `genesis_header_nav_priority` filter, with a default value of 12. Use a value of 6-9 to add the nav before the title + widget area, or 11-14 to add it after. If you want to add it in between, you'll need to remove and re-build `genesis_do_header()` function so that the output of the widget area is in a different function that can be hooked to a later priority.

To add the nav before the title + widget area markup in the source, you can use the following:

~~~php
add_filter( 'genesis_header_nav_priority', 'prefix_genesis_header_nav_priority' );
/**
* Change the order of the nav within the header (Genesis Header Nav plugin)
*
* @param int $priority Existing priority. Default is 12.
*
* @return int New priority.
*/
function prefix_genesis_header_nav_priority( $priority ) {
return 8;
}
~~~

## Credits

Built by [Gary Jones](https://twitter.com/GaryJ)
Expand Down
6 changes: 5 additions & 1 deletion class-genesis-header-nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ class Genesis_Header_Nav {
/**
* Initialize the plugin by setting localization, filters, and administration functions.
*
* Applies `genesis_header_nav_priority` filter. Use a value of 6-9 to add the nav before title + widget area, or
* 11-14 to add it after. If you want to add it in between, you'll need to remove and re-build `genesis_do_header()`
* so that the output of the widget area is in a different function that can be hooked to a later priority.
*
* @since 1.0.0
*/
private function __construct() {
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
add_action( 'genesis_setup', array( $this, 'register_nav_menu' ), 15 );
add_action( 'genesis_header', array( $this, 'show_menu' ), 8 );
add_action( 'genesis_header', array( $this, 'show_menu' ), apply_filters( 'genesis_header_nav_priority', 12 ) );
add_filter( 'body_class', array( $this, 'body_classes' ), 15 );
}

Expand Down
2 changes: 1 addition & 1 deletion genesis-header-nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Genesis Header Nav
* Plugin URI: https://github.com/GaryJones/genesis-header-nav
* Description: Registers a menu location and displays it inside the header for a Genesis Framework child theme.
* Version: 1.0.0
* Version: 1.1.0
* Author: Gary Jones
* Author URI: http://gamajo.com/
* Text Domain: genesis-header-nav
Expand Down

0 comments on commit 13a299b

Please sign in to comment.