/** * Echo the "Secondary Navigation" menu. * * Applies the `genesis_secondary_nav` and legacy `genesis_do_subnav` filters. * * Swaps in a Bootstrap-compatible menu-walker for Primary & Secondary menus * @link https://github.com/twittem/wp-bootstrap-navwalker Bootstrap Navwalker docs * * @since 1.0.0 * * @uses genesis_nav_menu() Display a navigation menu. * @uses genesis_nav_menu_supported() Checks for support of specific nav menu. */ function gb_genesis_do_subnav() { //* Do nothing if menu not supported if (!genesis_nav_menu_supported('secondary')) { return; } //$class = 'menu genesis-nav-menu menu-secondary'; $class = 'menu-secondary nav navbar-nav'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } ?> <div class="navbar navbar-default navbar-secondary"> <div class="container"> <div class="navbar-header"></div> <?php gb_genesis_nav_menu(array('theme_location' => 'secondary', 'menu_class' => $class, 'depth' => 2, 'container' => 'div', 'container_id' => 'nav-container-secondary', 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'walker' => new wp_bootstrap_navwalker())); ?> </div> </div> <?php }
/** * Display the menu. * * @since 1.0.0 */ public function show_menu() { $class = 'menu genesis-nav-menu menu-header'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } genesis_nav_menu(array('theme_location' => 'header', 'menu_class' => $class)); }
/** * Get a Genesis menu. * @since 1.0.0 */ public function get_custom_menu($class, $location) { $classes = 'menu genesis-nav-menu menu-primary' . $class; if (genesis_superfish_enabled()) { $classes .= 'js-superfish'; } $args = array('theme_location' => $location, 'menu-class' => $classes); $menu = genesis_get_nav_menu($args); return $menu; }
/** * Echo the "Secondary Navigation" menu. * * Applies the `genesis_secondary_nav` and legacy `genesis_do_subnav` filters. * * @since 1.0.0 * * @uses genesis_nav_menu() Display a navigation menu. * @uses genesis_nav_menu_supported() Checks for support of specific nav menu. */ function genesis_do_subnav() { //* Do nothing if menu not supported if (!genesis_nav_menu_supported('secondary')) { return; } $class = 'menu genesis-nav-menu menu-secondary'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } genesis_nav_menu(array('theme_location' => 'secondary', 'menu_class' => $class)); }
/** * Enqueue the scripts used on the front-end of the site. * * Includes comment-reply, superfish and the superfish arguments. * * @since 0.2.0 */ function genesis_load_scripts() { /** If a single post or page, threaded comments are enabled, and comments are open */ if (is_singular() && get_option('thread_comments') && comments_open()) { wp_enqueue_script('comment-reply'); } /** If superfish is enabled */ if (genesis_superfish_enabled()) { wp_enqueue_script('superfish', GENESIS_JS_URL . '/menu/superfish.js', array('jquery'), '1.4.8', true); wp_enqueue_script('superfish-args', GENESIS_JS_URL . '/menu/superfish.args.js', array('superfish'), PARENT_THEME_VERSION, true); } }
function foundation_do_nav() { //* Do nothing if menu not supported if (!genesis_nav_menu_supported('primary') || !has_nav_menu('primary')) { return; } $class = 'menu'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } if (genesis_a11y('headings')) { printf('<h2 class="screen-reader-text">%s</h2>', __('Main navigation', 'genesis')); } genesis_nav_menu(array('theme_location' => 'primary', 'menu_class' => $class)); }
/** * Enqueue the scripts used on the front-end of the site. * * Includes comment-reply, superfish and the superfish arguments. * * Applies the `genesis_superfish_enabled`, and `genesis_superfish_args_uri`. filter. * * @since 0.2.0 * * @uses genesis_html5() Check for HTML5 support. * @uses genesis_get_option() Get theme setting value. */ function genesis_load_scripts() { //* If a single post or page, threaded comments are enabled, and comments are open if (is_singular() && get_option('thread_comments') && comments_open()) { wp_enqueue_script('comment-reply'); } //* If superfish is enabled if (genesis_superfish_enabled()) { wp_enqueue_script('superfish'); wp_enqueue_script('superfish-args'); //* Load compatibility script if not running HTML5 if (!genesis_html5()) { wp_enqueue_script('superfish-compat'); } } }
/** * Return the markup to display a menu consistent with the Genesis format. * * Applies the `genesis_$location_nav` filter e.g. `genesis_header_nav`. For primary and secondary menu locations, it * applies the `genesis_do_nav` and `genesis_do_subnav` filters instead for backwards compatibility. * * @since 2.1.0 * * @param string|array $args Menu arguments. * @return string|null Navigation menu markup, or `null` if menu is not assigned to theme location, there is * no menu, or there are no menu items in the menu. */ function genesis_get_nav_menu($args = array()) { $args = wp_parse_args($args, array('theme_location' => '', 'container' => '', 'menu_class' => 'menu genesis-nav-menu', 'link_before' => genesis_html5() ? sprintf('<span %s>', genesis_attr('nav-link-wrap')) : '', 'link_after' => genesis_html5() ? '</span>' : '', 'echo' => 0)); // If a menu is not assigned to theme location, abort. if (!has_nav_menu($args['theme_location'])) { return; } // If genesis-accessibility for 'drop-down-menu' is enabled and the menu doesn't already have the superfish class, add it. if (genesis_superfish_enabled() && false === strpos($args['menu_class'], 'js-superfish')) { $args['menu_class'] .= ' js-superfish'; } $sanitized_location = sanitize_key($args['theme_location']); $nav = wp_nav_menu($args); // Do nothing if there is nothing to show. if (!$nav) { return; } $nav_markup_open = genesis_structural_wrap('menu-' . $sanitized_location, 'open', 0); $nav_markup_close = genesis_structural_wrap('menu-' . $sanitized_location, 'close', 0); $params = array('theme_location' => $args['theme_location']); $nav_output = genesis_markup(array('open' => '<nav %s>', 'close' => '</nav>', 'context' => 'nav-' . $sanitized_location, 'content' => $nav_markup_open . $nav . $nav_markup_close, 'echo' => false, 'params' => $params)); $filter_location = 'genesis_' . $sanitized_location . '_nav'; // Handle back-compat for primary and secondary nav filters. if ('primary' === $args['theme_location']) { $filter_location = 'genesis_do_nav'; } elseif ('secondary' === $args['theme_location']) { $filter_location = 'genesis_do_subnav'; } /** * Filter the navigation markup. * * @since 2.1.0 * * @param string $nav_output Opening container markup, nav, closing container markup. * @param string $nav Navigation list (`<ul>`). * @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 `<ul>`. * @type bool $echo 0 to indicate `wp_nav_menu()` should return not echo. * } */ return apply_filters($filter_location, $nav_output, $nav, $args); }
function gfb_menu() { if (has_nav_menu('gfb_footer_menu')) { $class = 'menu genesis-nav-menu menu-footer gfb-menu-footer'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $args = array('theme_location' => 'gfb_footer_menu', 'container' => 'genesis-nav-menu', 'menu_class' => $class, 'depth' => 1, 'echo' => 0); $nav = wp_nav_menu($args); if (!$nav) { return; } $nav_markup_open = genesis_markup(array('html5' => '<nav %s>', 'xhtml' => '<div id="gfb-menu-footer menu">', 'context' => 'footer-menu', 'echo' => false)); $nav_markup_close = genesis_html5() ? '</nav>' : '</div>'; $nav_output = $nav_markup_open . $nav . $nav_markup_close; echo apply_filters('gfb_menu', $nav_output, $nav, $args); } }
/** * Enqueue the scripts used on the front-end of the site. * * Includes comment-reply, superfish and the superfish arguments. * * Applies the `genesis_superfish_enabled`, and `genesis_superfish_args_uri`. filter. * * @since 0.2.0 * * @uses genesis_html5() Check for HTML5 support. * @uses genesis_get_option() Get theme setting value. */ function genesis_load_scripts() { global $wp_scripts; //* If a single post or page, threaded comments are enabled, and comments are open if (is_singular() && get_option('thread_comments') && comments_open()) { wp_enqueue_script('comment-reply'); } //* If superfish is enabled if (genesis_superfish_enabled()) { wp_enqueue_script('superfish'); wp_enqueue_script('superfish-args'); //* Load compatibility script if not running HTML5 if (!genesis_html5()) { wp_enqueue_script('superfish-compat'); } } //* If accessibility support enabled if (genesis_a11y('skip-links')) { wp_enqueue_script('skip-links'); } //* HTML5 shiv wp_enqueue_script('html5shiv'); $wp_scripts->add_data('html5shiv', 'conditional', 'lt IE 9'); }
/** * Render the specified nav * * @since 1.0.0 * * @param string $html Placeholder for the returning HTML * @param string $theme_location Theme's location for this nav * @param string $menu_name Added to the class to identify the nav * @return string|bool */ public function render_nav($html, $theme_location, $menu_name) { if (!genesis_nav_menu_supported($theme_location)) { return false; } $class = 'menu genesis-nav-menu menu-' . $menu_name; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } return genesis_nav_menu(array('theme_location' => $theme_location, 'menu_class' => $class, 'echo' => false)); }
/** * 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 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 `genesis_do_subnav`. * * @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 genesis_do_subnav() { //* Do nothing if menu not supported if (!genesis_nav_menu_supported('secondary')) { return; } //* If menu is assigned to theme location, output if (has_nav_menu('secondary')) { $class = 'menu genesis-nav-menu menu-secondary'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $args = array('theme_location' => 'secondary', 'container' => '', 'menu_class' => $class, 'echo' => 0); $subnav = wp_nav_menu($args); //* Do nothing if there is nothing to show if (!$subnav) { return; } $subnav_markup_open = genesis_markup(array('html5' => '<nav %s>', 'xhtml' => '<div id="subnav">', 'context' => 'nav-secondary', 'echo' => false)); $subnav_markup_open .= genesis_structural_wrap('menu-secondary', 'open', 0); $subnav_markup_close = genesis_structural_wrap('menu-secondary', 'close', 0); $subnav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; $subnav_output = $subnav_markup_open . $subnav . $subnav_markup_close; echo apply_filters('genesis_do_subnav', $subnav_output, $subnav, $args); } }
/** * Replaces Default Navigation and adds the "und" Logo */ function und_do_nav() { //* Do nothing if menu not supported if (!genesis_nav_menu_supported('primary')) { return; } $class = 'menu genesis-nav-menu menu-primary'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $items_wrap = '<ul id="%1$s" class="%2$s"><li class="logo-icon-li"><a href="/"><svg class="icon icon-logo logo-icon-und" viewBox="0 0 77 32"><use xlink:href="#icon-logo"></use></svg></a></li>%3$s</ul>'; genesis_nav_menu(array('theme_location' => 'primary', 'menu_class' => $class, 'items_wrap' => $items_wrap)); }
function zp_filter_genesis_subnav($nav_output, $nav, $args) { if (!genesis_nav_menu_supported('secondary')) { return; } if (!is_home() || !is_front_page()) { //* If menu is assigned to theme location, output if (has_nav_menu('secondary')) { $class = 'menu genesis-nav-menu menu-secondary nav navbar-nav pull-right'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $args = array('theme_location' => 'secondary', 'container' => '', 'menu_class' => $class, 'echo' => 0); $subnav = wp_nav_menu($args); //* Do nothing if there is nothing to show if (!$subnav) { return; } $subnav_markup_open = genesis_markup(array('html5' => '<nav %s>', 'xhtml' => '<div id="subnav">', 'context' => 'nav-secondary', 'echo' => false)); $subnav_markup_open .= genesis_structural_wrap('menu-secondary', 'open', 0); $subnav_markup_close = genesis_structural_wrap('menu-secondary', 'close', 0); $subnav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; $subnav_output = $subnav_markup_open . $subnav . $subnav_markup_close; } return $subnav_output; } }
/** * Sets a common class, `.genesis-nav-menu`, for the custom menu widget if used in the header right sidebar. * * @since 1.9.0 * * @uses genesis_html5() Check for HTML5 support. * @uses genesis_superfish_enabled() Check for superfish support. * * @param array $args Header menu args. * * @return array $args Modified header menu args. */ function genesis_header_menu_args($args) { $args['container'] = genesis_html5() ? '' : 'div'; $args['link_before'] = $args['link_before'] ? $args['link_before'] : sprintf('<span %s>', genesis_attr('nav-link-wrap')); $args['link_after'] = $args['link_after'] ? $args['link_after'] : '</span>'; $args['menu_class'] .= ' genesis-nav-menu'; $args['menu_class'] .= genesis_superfish_enabled() ? ' js-superfish' : ''; return $args; }
function themeprefix_modify_genesis_do_nav($nav_output, $nav, $args) { $class = 'menu genesis-nav-menu menu-primary'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $args = array('theme_location' => 'primary', 'container' => '', 'menu_class' => $class, 'echo' => 0); $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 id="primary-nav">', 'xhtml' => '<div id="nav">', 'context' => 'nav-primary', 'echo' => false)); $nav_markup_close .= genesis_html5() ? '</nav>' : '</div>'; $nav_output = $nav_markup_open . $nav . $nav_markup_close; // return the modified result return sprintf($nav_output, $nav, $args); }
/** * Sets a common class, `.genesis-nav-menu`, for the custom menu widget if used in the header right sidebar. * * @since 1.9.0 * * @uses genesis_html5() Check for HTML5 support. * @uses genesis_superfish_enabled() Check for superfish support. * * @param array $args Header menu args. * * @return array $args Modified header menu args. */ function genesis_header_menu_args($args) { $args['container'] = genesis_html5() ? '' : 'div'; $args['menu_class'] .= ' genesis-nav-menu'; $args['menu_class'] .= genesis_superfish_enabled() ? ' js-superfish' : ''; return $args; }