-
-
Save GaryJones/1799174 to your computer and use it in GitHub Desktop.
Add widget area before primary menu items in Genesis.
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_nav_items', 'sws_social_icons', 10, 2 ); | |
add_filter( 'wp_nav_menu_items', 'sws_social_icons', 10, 2 ); | |
/** | |
* Adds a widget area before primary menu items. | |
* | |
* @author Bill Erickson | |
* @author Gary Jones | |
* @link https://gist.github.com/gists/1799174 | |
* | |
* @param string $menu Existing menu items markup. | |
* @param array $args Menu arguments. | |
* | |
* @return string Amended menu items markup. | |
*/ | |
function sws_social_icons( $menu, array $args ) { | |
if ( 'primary' !== $args['theme_location'] ) | |
return $menu; | |
ob_start(); | |
dynamic_sidebar( 'social-menu' ); | |
return ob_get_clean() . $menu; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's not great for performance, but if a function immediately echoes rather than returns, then there's no choice. Genesis uses it in one or two places for the same reason.