From 13a299bfe88deb13c5b4c7a19c01ec9be15aa3a6 Mon Sep 17 00:00:00 2001 From: GaryJones Date: Fri, 30 Aug 2013 15:58:04 +0100 Subject: [PATCH] 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. --- README.md | 24 ++++++++++++++++++++++++ class-genesis-header-nav.php | 6 +++++- genesis-header-nav.php | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fc412c..d85ed88 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/class-genesis-header-nav.php b/class-genesis-header-nav.php index 4a6d2be..a731854 100644 --- a/class-genesis-header-nav.php +++ b/class-genesis-header-nav.php @@ -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 ); } diff --git a/genesis-header-nav.php b/genesis-header-nav.php index 772bf8c..f2e9b93 100644 --- a/genesis-header-nav.php +++ b/genesis-header-nav.php @@ -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