Last active
December 20, 2015 20:09
-
-
Save bradpotter/6188509 to your computer and use it in GitHub Desktop.
Create the Mobile Navigation Menu
This file contains 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
add_action( 'genesis_before_header', 'gst_do_mobilenav' ); | |
/** | |
* Create the Mobile Navigation Menu. | |
* | |
* @author Brad Potter | |
* | |
* @link http://www.bradpotter.com | |
* | |
* Based on code from the StudioPress Genesis Framework 2.0 | |
*/ | |
function gst_do_mobilenav() { | |
//* Do nothing if menu not supported | |
if ( ! genesis_nav_menu_supported( 'mobile' ) ) | |
return; | |
//* If menu is assigned to theme location, output | |
if ( has_nav_menu( 'mobile' ) ) { | |
$class = 'menu genesis-nav-menu menu-mobile'; | |
if ( genesis_superfish_enabled() ) | |
$class .= ' js-superfish'; | |
$args = array( | |
'theme_location' => 'mobile', | |
'container' => '', | |
'menu_class' => $class, | |
'echo' => 0, | |
); | |
$mobilenav = wp_nav_menu( $args ); | |
//* Do nothing if there is nothing to show | |
if ( ! $mobilenav ) | |
return; | |
$mobilenav_markup_open = genesis_markup( array( | |
'html5' => '<nav %s>', | |
'xhtml' => '<div id="mobilenav">', | |
'context' => 'nav-mobile', | |
'echo' => false, | |
) ); | |
$mobilenav_markup_open .= genesis_structural_wrap( 'menu-mobile', 'open', 0 ); | |
$mobilenav_markup_close = genesis_structural_wrap( 'menu-mobile', 'close', 0 ); | |
$mobilenav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; | |
$mobilenav_output = $mobilenav_markup_open . $mobilenav . $mobilenav_markup_close; | |
echo apply_filters( 'gst_do_mobilenav', $mobilenav_output, $mobilenav, $args ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment