-
-
Save bryanwillis/963e3edb9de0cb3d9925 to your computer and use it in GitHub Desktop.
By default, the Genesis header-right widget area uses an <aside> element. While this is fine most of the time, if you're using the header-right section for your primary navigation it is probably less than ideal for it to be wrapped in an <aside>. This will change the <aside> to a standard <div> element.
This file contains hidden or 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
| <?php | |
| add_filter( 'genesis_markup_header-widget-area_output', 'prefix_opening_header_div', 10, 2 ); | |
| /** | |
| * Replace the opening header-right <aside> tag with a <div> tag to allow the | |
| * primary nav to be used in the header without being wrapped in an aside tag. | |
| * | |
| * @param $tag string The current tag for the .header-right widget area. | |
| * @param $args array The current args for genesis_attr() | |
| * @return $tag string The modified tag for the .header-right widget area. | |
| */ | |
| function prefix_opening_header_div( $tag, $args ) { | |
| $tag = '<div ' . genesis_attr( $args['context'] ) . '>'; | |
| return $tag; | |
| } | |
| add_filter( 'genesis_markup_', 'prefix_header_closing_div', 10, 2 ); | |
| /** | |
| * Replace the closing header-right </aside> tag with a </div> tag to allow the | |
| * primary nav to be used in the header without being wrapped in an aside tag. | |
| * | |
| * @param $tag string The current tag for the .header-right widget area. | |
| * @param $args array The current args for genesis_attr() | |
| * @return $tag string The modified tag for the .header-right widget area. | |
| */ | |
| function prefix_header_closing_div( $tag, $args ) { | |
| if ( did_action( 'genesis_header' ) && ! did_action( 'genesis_after_header' ) ) { | |
| $tag = str_replace( '</aside>', '</div>', $args['html5'] ); | |
| } | |
| if ( $args['echo'] ) { | |
| echo $tag; | |
| } | |
| return $tag; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment