'',
'container' => '',
'menu_class' => 'menu menu-bizznis',
'echo' => 0,
) );
# If a menu is not assigned to theme location, abort
if ( ! has_nav_menu( $args['theme_location'] ) ) {
return;
}
$sanitized_location = sanitize_key( $args['theme_location'] );
$nav = wp_nav_menu( $args );
$nav = apply_filters( "nav_{$sanitized_location}_before", '', $args );
$nav .= wp_nav_menu( $args );
$nav .= apply_filters( "nav_{$sanitized_location}_after", '', $args );
# Do nothing if there is nothing to show
if ( ! $nav ) {
return;
}
$nav_markup_open = sprintf( '';
$nav_output = $nav_markup_open . $nav . $nav_markup_close;
$filter_location = 'bizznis_' . $sanitized_location . '_nav';
# Handle back-compat for primary and secondary nav filters.
if ( 'primary' === $args['theme_location'] ) {
$filter_location = 'bizznis_do_nav';
} elseif ( 'secondary' === $args['theme_location'] ) {
$filter_location = 'bizznis_do_subnav';
}
/**
* Filter the navigation markup.
*
* @since 1.1.0
*
* @param string $nav_output Opening container markup, nav, closing container markup.
* @param string $nav Navigation list (`
`).
* @param array $args {
* Arguments for `wp_nav_menu()`.
*
* @type string $theme_location Menu location ID.
* @type string $container Container markup.
* @type string $menu_class Class(es) applied to the ``.
* @type bool $echo 0 to indicate `wp_nav_menu()` should return not echo.
* }
*/
return apply_filters( $filter_location, $nav_output, $nav, $args );
}
/**
* Echo the output from `bizznis_get_nav_menu()`.
*
* @since 1.1.0
*
* @uses bizznis_get_nav_menu() Return the markup to display a menu consistent with the Genesis format.
*
* @param string $args Menu arguments.
*/
function bizznis_nav_menu( $args ) {
echo bizznis_get_nav_menu( $args );
}
/**
* Register the custom menu locations, if theme has support for them.
*
* Does the `bizznis_register_nav_menus` action.
*
* @since 1.0.0
*/
add_action( 'after_setup_theme', 'bizznis_register_nav_menus' );
function bizznis_register_nav_menus() {
# Stop here if menus not supported
if ( ! current_theme_supports( 'bizznis-menus' ) ) {
return;
}
$menus = get_theme_support( 'bizznis-menus' );
# Register supported menus
register_nav_menus( (array) $menus[0] );
do_action( 'bizznis_register_nav_menus' );
}
/**
* Add navigation menu description
*
* Optionally call it inside a child theme
*
* @since 1.0.0
*/
// add_filter( 'walker_nav_menu_start_el', 'bizznis_add_menu_description', 10, 2 );
function bizznis_add_menu_description( $item_output, $item ) {
$description = $item->post_content;
if ( ' ' !== $description ) {
return preg_replace( '/([^<]*?)', '$1' . '<', $item_output);
}
else {
return $item_output;
}
}