Skip to content

Commit 13a299b

Browse files
committed
Add filter for nav priority within header.
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.
1 parent 12f5dc9 commit 13a299b

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ Then go to your Plugins screen and click __Activate__.
5555

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

58+
## Customising
59+
60+
### CSS
61+
5862
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.:
5963

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

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

74+
### Priority
75+
76+
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.
77+
78+
To add the nav before the title + widget area markup in the source, you can use the following:
79+
80+
~~~php
81+
add_filter( 'genesis_header_nav_priority', 'prefix_genesis_header_nav_priority' );
82+
/**
83+
* Change the order of the nav within the header (Genesis Header Nav plugin)
84+
*
85+
* @param int $priority Existing priority. Default is 12.
86+
*
87+
* @return int New priority.
88+
*/
89+
function prefix_genesis_header_nav_priority( $priority ) {
90+
return 8;
91+
}
92+
~~~
93+
7094
## Credits
7195

7296
Built by [Gary Jones](https://twitter.com/GaryJ)

class-genesis-header-nav.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ class Genesis_Header_Nav {
2929
/**
3030
* Initialize the plugin by setting localization, filters, and administration functions.
3131
*
32+
* Applies `genesis_header_nav_priority` filter. Use a value of 6-9 to add the nav before title + widget area, or
33+
* 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()`
34+
* so that the output of the widget area is in a different function that can be hooked to a later priority.
35+
*
3236
* @since 1.0.0
3337
*/
3438
private function __construct() {
3539
add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
3640
add_action( 'genesis_setup', array( $this, 'register_nav_menu' ), 15 );
37-
add_action( 'genesis_header', array( $this, 'show_menu' ), 8 );
41+
add_action( 'genesis_header', array( $this, 'show_menu' ), apply_filters( 'genesis_header_nav_priority', 12 ) );
3842
add_filter( 'body_class', array( $this, 'body_classes' ), 15 );
3943
}
4044

genesis-header-nav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin Name: Genesis Header Nav
1313
* Plugin URI: https://github.com/GaryJones/genesis-header-nav
1414
* Description: Registers a menu location and displays it inside the header for a Genesis Framework child theme.
15-
* Version: 1.0.0
15+
* Version: 1.1.0
1616
* Author: Gary Jones
1717
* Author URI: http://gamajo.com/
1818
* Text Domain: genesis-header-nav

0 commit comments

Comments
 (0)