Skip to content

Commit 841fd08

Browse files
committed
Merge branch 'release/1.3.0'
2 parents b37e8bd + 6ae5270 commit 841fd08

File tree

4 files changed

+31
-43
lines changed

4 files changed

+31
-43
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,24 @@ The default method of getting a menu to appear in the top right of a site using
88

99
* Since the menu is output from a widget, you end up with all of the extraneous widget and widget area markup - in a child theme with HTML5 support, that's the widget area `aside`, the widget `section`, and the widget wrap `div`. In themes without HTML5 support, it's three levels of `div` elements instead. Not only is this more DOM elements to render (performance), but all markup in the site header is pushing the real page content further down the source; search engines apparently put higher value on content at the top of the source (which is why Genesis ensures primary and secondary sidebars come lower in the source than the main content, irrespective of where they are displayed on screen).
1010
* In HTML5 themes, what could be a site's main navigation is wrapped in an `aside` element. It's not known whether this has any impact on SEO. Theoretically at least, search engines may put less value on navigation found in an `aside` or otherwise treat it differently.
11-
11+
12+
> "_I can't think of any good reason to use an aside in a header... what the hell would it be contextually related to? The logo? lol_" - **Robert Neu**
13+
1214
This plugin registers a new menu location called Header and, if a menu is assigned to it, displays it before the Header Right area. If you don't have any widgets in the Header Right area, then Genesis ensures that none of that widget area markup is output, so you end up with code like screenshot 2. If you do want a widget in the Header Right area, that's fine - it can be positioned and styled as you want, without negatively affecting the navigation menu as well.
1315

1416
## Screenshots
1517

1618
![Screenshot of markup using Custom Menu widget](assets/screenshot-1.png)
17-
_Screenshot 1: Markup using Custom Menu widget._
19+
_Screenshot 1: Markup using Custom Menu widget. Note the `aside`, `section` and `div` parents to `nav`._
1820

1921
---
2022

2123
![Screenshot of markup using this plugin](assets/screenshot-2.png)
22-
_Screenshot 2: Markup using this plugin._
24+
_Screenshot 2: Markup using this plugin. `nav` is a sibling element to the title area `div`._
2325

2426
## Requirements
2527
* WordPress 3.0+
26-
* Genesis 2.0+
28+
* Genesis 2.1+
2729

2830
## Installation
2931

@@ -59,6 +61,10 @@ This plugin supports the [GitHub Updater](https://github.com/afragen/github-upda
5961

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

64+
## Backwards-incompatible Changes
65+
66+
The hook that filters the menu was called `genesis_do_header_nav` but is now called `genesis_header_nav` due to using the `genesis_header_nav()` function in Genesis 2.1.
67+
6268
## Customising
6369

6470
### CSS
@@ -86,9 +92,9 @@ add_filter( 'genesis_header_nav_priority', 'prefix_genesis_header_nav_priority'
8692
/**
8793
* Change the order of the nav within the header (Genesis Header Nav plugin)
8894
*
89-
* @param int $priority Existing priority. Default is 12.
95+
* @param int $priority Existing priority. Default is 12.
9096
*
91-
* @return int New priority.
97+
* @return int New priority.
9298
*/
9399
function prefix_genesis_header_nav_priority( $priority ) {
94100
return 8;
@@ -103,10 +109,15 @@ If you give the above priority filter a value of less than 5, then the output wi
103109
add_filter( 'gettext', 'prefix_genesis_header_nav_name', 10, 3 );
104110
/**
105111
* Change the name of the Header menu location added by Genesis Header Nav plugin.
112+
*
113+
* @param string $translated_text Translated text.
114+
* @param string $original_text Original text.
115+
* @param string $domain Text domain.
106116
*/
107117
function prefix_genesis_header_nav_name( $translated_text, $original_text, $domain ) {
108-
if ( 'genesis-header-nav' === $domain && 'Header' === $original_text )
118+
if ( 'genesis-header-nav' === $domain && 'Header' === $original_text ) {
109119
return 'Top';
120+
}
110121
}
111122
~~~
112123

@@ -115,8 +126,9 @@ function prefix_genesis_header_nav_name( $translated_text, $original_text, $doma
115126
If you want the menu to not display, perhaps on a landing page, then you can do the following:
116127

117128
~~~php
118-
if ( class_exists( 'Genesis_Header_Nav' ) )
129+
if ( class_exists( 'Genesis_Header_Nav' ) ) {
119130
remove_action( 'genesis_header', array( Genesis_Header_Nav::get_instance(), 'show_menu' ), apply_filters( 'genesis_header_nav_priority', 12 ) );
131+
}
120132
~~~
121133

122134
## Credits

class-genesis-header-nav.php

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,41 +86,17 @@ public function register_nav_menu() {
8686
* @since 1.0.0
8787
*/
8888
public function show_menu() {
89-
//* If menu is assigned to theme location, output
90-
if ( ! has_nav_menu( 'header' ) )
91-
return;
92-
9389
$class = 'menu genesis-nav-menu menu-header';
94-
if ( genesis_superfish_enabled() )
90+
if ( genesis_superfish_enabled() ) {
9591
$class .= ' js-superfish';
92+
}
9693

97-
$args = array(
98-
'theme_location' => 'header',
99-
'container' => '',
100-
'menu_class' => $class,
101-
'echo' => 0,
94+
genesis_nav_menu(
95+
array(
96+
'theme_location' => 'header',
97+
'menu_class' => $class,
98+
)
10299
);
103-
104-
$nav = wp_nav_menu( $args );
105-
106-
//* Do nothing if there is nothing to show
107-
if ( ! $nav )
108-
return;
109-
110-
$nav_markup_open = genesis_markup( array(
111-
'html5' => '<nav %s>',
112-
'xhtml' => '<div id="nav">',
113-
'context' => 'nav-header',
114-
'echo' => false,
115-
) );
116-
$nav_markup_open .= genesis_structural_wrap( 'menu-header', 'open', 0 );
117-
118-
$nav_markup_close = genesis_structural_wrap( 'menu-header', 'close', 0 );
119-
$nav_markup_close .= genesis_html5() ? '</nav>' : '</div>';
120-
121-
$nav_output = $nav_markup_open . $nav . $nav_markup_close;
122-
123-
echo apply_filters( 'genesis_do_header_nav', $nav_output, $nav, $args );
124100
}
125101

126102
/**

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.2.0
15+
* Version: 1.3.0
1616
* Author: Gary Jones
1717
* Author URI: http://gamajo.com/
1818
* Text Domain: genesis-header-nav

languages/genesis-header-nav.pot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# This file is distributed under the GPL-2.0+.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Genesis Header Nav v1.0.0\n"
6-
"POT-Creation-Date: 2013-08-30 11:33:00+0000\n"
7-
"PO-Revision-Date: 2013-08-30 11:33:00+0000\n"
5+
"Project-Id-Version: Genesis Header Nav v1.3.0\n"
6+
"POT-Creation-Date: 2014-10-30 00:13:00+0000\n"
7+
"PO-Revision-Date: 2014-10-30 00:13:00+0000\n"
88
"Report-Msgid-Bugs-To: https://github.com/GaryJones/genesis-header-nav/issues \n"
99
"Last-Translator: Gary Jones <gary@garyjones.co.uk>\n"
1010
"Language-Team: English https://github.com/GaryJones/genesis-header-nav \n"

0 commit comments

Comments
 (0)