|
<?php |
|
|
|
add_action( 'after_setup_theme', 'prefix_add_tertiary_menu_support', 0 ); |
|
/** |
|
* Register the tertiary menu locations without overriding any other child theme settings. |
|
* |
|
* @return null Returns early if no Genesis menus are supported. |
|
*/ |
|
function prefix_add_tertiary_menu_support() { |
|
$menus = get_theme_support( 'genesis-menus' ); |
|
$tertiary = array( |
|
'tertiary' => __( 'Tertiary Navigation Menu', 'text-domain' ), |
|
); |
|
// If no other menus exist, add the tertiary and end here. |
|
if ( empty( $menus ) ) { |
|
add_theme_support( 'genesis-menus', $tertiary ); |
|
return; |
|
} |
|
// Merge the tertiary menu in with other theme menu locations. |
|
$menus = array_merge( $menus[0], $tertiary ); |
|
add_theme_support( 'genesis-menus', $menus ); |
|
} |
|
|
|
add_action( 'genesis_after_header', 'prefix_do_tertiary_nav' ); |
|
/** |
|
* Echo the "Tertiary Navigation" menu. |
|
* |
|
* The preferred option for creating menus is the Custom Menus feature in WordPress. There is also a fallback to using |
|
* the Genesis wrapper functions for creating a menu of Pages, or a menu of Categories (maintained only for backwards |
|
* compatibility). |
|
* |
|
* Either output can be filtered via `prefix_do_tertiary_nav`. |
|
* |
|
* @since 1.0.0 |
|
* |
|
* @uses genesis_nav_menu_supported() Checks for support of specific nav menu. |
|
* @uses genesis_markup() Contextual markup. |
|
* @uses genesis_html5() Check for HTML5 support. |
|
* @uses genesis_structural_wrap() Adds optional internal wrap divs. |
|
*/ |
|
function prefix_do_tertiary_nav() { |
|
|
|
//* Do nothing if menu not supported |
|
if ( ! genesis_nav_menu_supported( 'tertiary' ) || ! has_nav_menu( 'tertiary' ) ) { |
|
return; |
|
} |
|
|
|
$class = 'menu genesis-nav-menu menu-tertiary'; |
|
if ( genesis_superfish_enabled() ) { |
|
$class .= ' js-superfish'; |
|
} |
|
|
|
$args = array( |
|
'theme_location' => 'tertiary', |
|
'container' => '', |
|
'menu_class' => $class, |
|
'echo' => 0, |
|
); |
|
|
|
// If Using Genesis 2.1+ output the genesis_nav_menu and end here. |
|
if ( function_exists( 'genesis_nav_menu' ) ) { |
|
genesis_nav_menu( $args); |
|
return; |
|
} |
|
|
|
$nav = wp_nav_menu( $args ); |
|
|
|
//* Do nothing if there is nothing to show |
|
if ( ! $nav ) { |
|
return; |
|
} |
|
|
|
$nav_markup_open = genesis_markup( array( |
|
'html5' => '<nav %s>', |
|
'xhtml' => '<div id="nav">', |
|
'context' => 'nav-tertiary', |
|
'echo' => false, |
|
) ); |
|
$nav_markup_open .= genesis_structural_wrap( 'menu-tertiary', 'open', 0 ); |
|
|
|
$nav_markup_close = genesis_structural_wrap( 'menu-tertiary', 'close', 0 ); |
|
$nav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; |
|
|
|
$nav_output = $nav_markup_open . $nav . $nav_markup_close; |
|
|
|
echo apply_filters( 'prefix_do_tertiary_nav', $nav_output, $nav, $args ); |
|
|
|
} |