$name ) { register_nav_menu( $id, $name ); } do_action( 'bizznis_register_nav_menus' ); } /** * Echo the "Primary Navigation" menu. * * The preferred option for creating menus is the Custom Menus feature in WordPress. There is also a fallback to using * the Bizznis wrapper functions for creating a menu of Pages, or a menu of Categories (maintained only for backwards * compatibility). * * Either output can be filtered via `bizznis_do_nav`. * * @since 1.0.0 */ add_action( 'bizznis_header_top', 'bizznis_do_nav' ); function bizznis_do_nav() { # Stop here if menu not supported if ( ! bizznis_nav_menu_supported( 'primary' ) ) { return; } # If menu is assigned to theme location, output if ( has_nav_menu( 'primary' ) ) { $args = array( 'theme_location' => 'primary', 'container' => '', 'menu_class' => 'menu menu-bizznis menu-primary', 'echo' => 0, ); $nav = apply_filters( 'nav_primary_before', '', $args ); $nav .= wp_nav_menu( $args ); $nav .= apply_filters( 'nav_primary_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; echo apply_filters( 'bizznis_do_nav', $nav_output, $nav, $args ); } } /** * Echo the "Secondary Navigation" menu. * * The preferred option for creating menus is the Custom Menus feature in WordPress. There is also a fallback to using * the Bizznis wrapper functions for creating a menu of Pages, or a menu of Categories (maintained only for backwards * compatibility). * * Either output can be filtered via `bizznis_do_subnav`. * * @since 1.0.0 */ add_action( 'bizznis_header_bottom', 'bizznis_do_subnav' ); function bizznis_do_subnav() { # Do nothing if menu not supported if ( ! bizznis_nav_menu_supported( 'secondary' ) ) { return; } # If menu is assigned to theme location, output if ( has_nav_menu( 'secondary' ) ) { $args = array( 'theme_location' => 'secondary', 'container' => '', 'menu_class' => 'menu menu-bizznis menu-secondary', 'echo' => 0, ); $subnav = apply_filters( 'nav_secondary_before', '', $args ); $subnav .= wp_nav_menu( $args ); $subnav .= apply_filters( 'nav_secondary_after', '', $args ); # Do nothing if there is nothing to show if ( ! $subnav ) { return; } $subnav_markup_open = sprintf( ''; $subnav_output = $subnav_markup_open . $subnav . $subnav_markup_close; echo apply_filters( 'bizznis_do_subnav', $subnav_output, $subnav, $args ); } } /** * Filter the Primary Navigation menu items, appending either RSS links, search form, twitter link, or today's date. * * @since 1.0.0 */ add_filter( 'nav_primary_after', 'bizznis_nav_right', 10, 2 ); function bizznis_nav_right( $menu = '', $args = '' ) { # Stop here if extras not enabled if ( ! bizznis_get_option( 'nav_extras_enable' ) ) { return $menu; } # show selected option switch ( bizznis_get_option( 'nav_extras' ) ) { case 'search': # I hate output buffering, but I have no choice ob_start(); get_search_form(); $search = ob_get_clean(); $menu .= '
'; break; case 'twitter': $menu .= sprintf( '', esc_url( 'http://twitter.com/' . bizznis_get_option( 'nav_extras_twitter_id' ) ), esc_html( bizznis_get_option( 'nav_extras_twitter_text' ) ) ); break; case 'date': $menu .= ''; break; } return $menu; } /** * Collapse primary menu for mobile screen * * @since 1.0.0 */ add_filter( 'nav_primary_before', 'bizznis_mobile_right', 10, 2 ); function bizznis_mobile_right( $menu = '', $args = '' ) { # show mobile menu toggle $menu .= ''; $menu .= ''; return $menu; } /** * Collapse secondary menu for mobile screen * * Optionally call it inside a Child theme * * @since 1.0.0 */ // add_filter( 'nav_secondary_before', 'bizznis_secondary_mobile_right', 10, 2 ); function bizznis_secondary_mobile_right( $menu = '', $args = '' ) { # show mobile menu toggle $menu .= ''; $menu .= ''; return $menu; } /** * Sets a common class, `.bizznis-nav-menu`, for the custom menu widget if used in the header sidebar. * * @since 1.0.0 */ function bizznis_header_menu_args( $args ) { $args['container'] = ''; $args['menu_class'] .= ' menu-bizznis'; return $args; } /** * Wrap the header navigation menu in its own nav tags with markup API. * * @since 1.0.0 */ function bizznis_header_menu_wrap( $menu ) { return sprintf( ''; } /** * 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( '/(