/** * 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 }
/** * 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. * * 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)); }
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)); }
/** * Echoes 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_get_option() Get theme setting value * @uses genesis_nav() Use old-style Genesis Pages or Categories menu * @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')) { $args = array('theme_location' => 'secondary', 'container' => '', 'menu_class' => genesis_get_option('subnav_superfish') ? 'menu genesis-nav-menu menu-secondary superfish' : 'menu genesis-nav-menu menu-secondary', 'echo' => 0); $subnav = wp_nav_menu($args); $pattern = genesis_markup('<nav class="secondary">%2$s%1$s%3$s</nav>', '<div id="subnav">%2$s%1$s%3$s</div>', 0); $subnav_output = sprintf($pattern, $subnav, genesis_structural_wrap('subnav', 'open', 0), genesis_structural_wrap('subnav', 'close', 0)); echo apply_filters('genesis_do_subnav', $subnav_output, $subnav, $args); } }
/** * Determines if the superfish script is enabled. * * @since 1.9.0 * * @return boolean */ function genesis_superfish_enabled() { /** Short circuit option */ $pre = apply_filters('genesis_superfish_enabled', null); if (null !== $pre) { return $pre; } /** If primary menu is active, and if the superfish setting is checked */ if (genesis_nav_menu_supported('primary') && genesis_get_option('nav_superfish')) { return true; } /** If secondary menu is active, and if the superfish setting is checked */ if (genesis_nav_menu_supported('secondary') && genesis_get_option('subnav_superfish')) { return true; } /** If a custom menu widget is in use on the site */ if (is_active_widget(0, 0, 'nav_menu')) { return true; } return 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); } }
/** * Callback for Theme Settings Navigation Settings meta box. * * @since 1.0.0 * * @uses genesis_nav_menu_supported() Determine if a child theme supports a particular Genesis nav menu. * @uses \Genesis_Admin::get_field_id() Construct field ID. * @uses \Genesis_Admin::get_field_name() Construct field name. * @uses \Genesis_Admin::get_field_value() Retrieve value of key under $this->settings_field. * * @see \Genesis_Admin_Settings::metaboxes() Register meta boxes on the Theme Settings page. */ function nav_box() { if (!genesis_html5()) { ?> <p> <input type = "checkbox" name="<?php $this->field_name('superfish'); ?> " id="<?php $this->field_id('superfish'); ?> " value="1"<?php checked($this->get_field_value('superfish')); ?> /> <label for="<?php $this->field_id('superfish'); ?> "><?php _e('Load Superfish Script?', 'genesis'); ?> </label> </p> <?php } if (genesis_nav_menu_supported('primary')) { ?> <h4><?php _e('Primary Navigation Extras', 'genesis'); ?> </h4> <?php if (!has_nav_menu('primary')) { ?> <p><span class="description"><?php printf(__('In order to view the Primary navigation menu settings, you must build a <a href="%s">custom menu</a>, then assign it to the Primary Menu Location.', 'genesis'), admin_url('nav-menus.php')); ?> </span></p> <?php } else { ?> <div id="genesis_nav_extras_settings"> <p> <label for="<?php $this->field_id('nav_extras'); ?> "><?php _e('Display the following:', 'genesis'); ?> </label> <select name="<?php $this->field_name('nav_extras'); ?> " id="<?php $this->field_id('nav_extras'); ?> "> <option value=""><?php _e('None', 'genesis'); ?> </option> <option value="date"<?php selected($this->get_field_value('nav_extras'), 'date'); ?> ><?php _e('Today\'s date', 'genesis'); ?> </option> <option value="rss"<?php selected($this->get_field_value('nav_extras'), 'rss'); ?> ><?php _e('RSS feed links', 'genesis'); ?> </option> <option value="search"<?php selected($this->get_field_value('nav_extras'), 'search'); ?> ><?php _e('Search form', 'genesis'); ?> </option> <option value="twitter"<?php selected($this->get_field_value('nav_extras'), 'twitter'); ?> ><?php _e('Twitter link', 'genesis'); ?> </option> </select> </p> <div id="genesis_nav_extras_twitter"> <p> <label for="<?php $this->field_id('nav_extras_twitter_id'); ?> "><?php _e('Enter Twitter ID:', 'genesis'); ?> </label> <input type="text" name="<?php $this->field_name('nav_extras_twitter_id'); ?> " id="<?php $this->field_id('nav_extras_twitter_id'); ?> " value="<?php echo esc_attr($this->get_field_value('nav_extras_twitter_id')); ?> " size="27" /> </p> <p> <label for="<?php $this->field_id('nav_extras_twitter_text'); ?> "><?php _e('Twitter Link Text:', 'genesis'); ?> </label> <input type="text" name="<?php $this->field_name('nav_extras_twitter_text'); ?> " id="<?php $this->field_id('nav_extras_twitter_text'); ?> " value="<?php echo esc_attr($this->get_field_value('nav_extras_twitter_text')); ?> " size="27" /> </p> </div> </div> <?php } } }
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; } }
/** * Add skiplinks for screen readers and keyboard navigation * * @since 2.2.0 */ function genesis_skip_links() { if (!genesis_a11y('skip-links')) { return; } // Call function to add IDs to the markup genesis_skiplinks_markup(); // Determine which skip links are needed $links = array(); if (genesis_nav_menu_supported('primary') && has_nav_menu('primary')) { $links['genesis-nav-primary'] = __('Skip to primary navigation', 'genesis'); } $links['genesis-content'] = __('Skip to content', 'genesis'); if ('full-width-content' != genesis_site_layout()) { $links['genesis-sidebar-primary'] = __('Skip to primary sidebar', 'genesis'); } if (in_array(genesis_site_layout(), array('sidebar-sidebar-content', 'sidebar-content-sidebar', 'content-sidebar-sidebar'))) { $links['genesis-sidebar-secondary'] = __('Skip to secondary sidebar', 'genesis'); } if (current_theme_supports('genesis-footer-widgets')) { $footer_widgets = get_theme_support('genesis-footer-widgets'); if (isset($footer_widgets[0]) && is_numeric($footer_widgets[0])) { if (is_active_sidebar('footer-1')) { $links['genesis-footer-widgets'] = __('Skip to footer', 'genesis'); } } } /** * Filter the skip links. * * @since 2.2.0 * * @param array $links { * Default skiplinks. * * @type string HTML ID attribute value to link to. * @type string Anchor text. * } */ $links = apply_filters('genesis_skip_links_output', $links); // write HTML, skiplinks in a list with a heading $skiplinks = '<section>'; $skiplinks .= '<h2 class="screen-reader-text">' . __('Skip links', 'genesis') . '</h2>'; $skiplinks .= '<ul class="genesis-skip-link">'; // Add markup for each skiplink foreach ($links as $key => $value) { $skiplinks .= '<li><a href="' . esc_url('#' . $key) . '" class="screen-reader-shortcut"> ' . $value . '</a></li>'; } $skiplinks .= '</ul>'; $skiplinks .= '</section>' . "\n"; echo $skiplinks; }
/** * Echoes 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_get_option() Get theme setting value * @uses genesis_nav() Use old-style Genesis Pages or Categories menu * @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 (genesis_get_option('subnav')) { if (has_nav_menu('secondary')) { $args = array('theme_location' => 'secondary', 'container' => '', 'menu_class' => genesis_get_option('subnav_superfish') ? 'menu menu-secondary superfish' : 'menu menu-secondary', 'echo' => 0); $subnav = wp_nav_menu($args); } elseif ('nav-menu' != genesis_get_option('subnav_type', 'genesis-vestige')) { $args = array('theme_location' => 'secondary', 'menu_class' => 'menu menu-secondary', 'show_home' => genesis_get_option('subnav_home', 'genesis-vestige'), 'type' => genesis_get_option('subnav_type', 'genesis-vestige'), 'sort_column' => genesis_get_option('subnav_pages_sort', 'genesis-vestige'), 'orderby' => genesis_get_option('subnav_categories_sort', 'genesis-vestige'), 'depth' => genesis_get_option('subnav_depth', 'genesis-vestige'), 'exclude' => genesis_get_option('subnav_exclude', 'genesis-vestige'), 'include' => genesis_get_option('subnav_include', 'genesis-vestige'), 'echo' => false); $subnav = genesis_nav($args); } $subnav_output = sprintf('<div id="subnav">%2$s%1$s%3$s</div>', $subnav, genesis_structural_wrap('subnav', 'open', 0), genesis_structural_wrap('subnav', 'close', 0)); echo apply_filters('genesis_do_subnav', $subnav_output, $subnav, $args); } }
/** * Callback for Theme Settings Navigation Settings meta box. * * @category Genesis * @package Admin * @subpackage Theme-Settings * * @since 1.0.0 * * @uses Genesis_Admin::get_field_name() Construct full field name * @uses Genesis_Admin::get_field_value() Retrieve value of key under $this->settings_field * * @see Genesis_Admin_Settings::metaboxes() */ function nav_box() { ?> <?php if (genesis_nav_menu_supported('primary')) { ?> <h4><?php _e('Primary Navigation', 'genesis'); ?> </h4> <p> <input type="checkbox" name="<?php echo $this->get_field_name('nav'); ?> " id="<?php echo $this->get_field_id('nav'); ?> " value="1"<?php checked($this->get_field_value('nav')); ?> /> <label for="<?php echo $this->get_field_id('nav'); ?> "><?php _e('Include Primary Navigation Menu?', 'genesis'); ?> </label> </p> <div id="genesis_nav_settings"> <p> <input type="checkbox" name="<?php echo $this->get_field_name('nav_superfish'); ?> " id="<?php echo $this->get_field_id('nav_superfish'); ?> " value="1"<?php checked($this->get_field_value('nav_superfish')); ?> /> <label for="<?php echo $this->get_field_id('nav_superfish'); ?> "><?php _e('Enable Fancy Dropdowns?', 'genesis'); ?> </label> </p> <p> <input type="checkbox" name="<?php echo $this->get_field_name('nav_extras_enable'); ?> " id="<?php echo $this->get_field_id('nav_extras_enable'); ?> " value="1"<?php checked($this->get_field_value('nav_extras_enable')); ?> /> <label for="<?php echo $this->get_field_id('nav_extras_enable'); ?> "><?php _e('Enable Extras on Right Side?', 'genesis'); ?> </label> </p> <div id="genesis_nav_extras_settings"> <p> <label for="<?php echo $this->get_field_id('nav_extras'); ?> "><?php _e('Display the following:', 'genesis'); ?> </label> <select name="<?php echo $this->get_field_name('nav_extras'); ?> " id="<?php echo $this->get_field_id('nav_extras'); ?> "> <option value="date"<?php selected($this->get_field_value('nav_extras'), 'date'); ?> ><?php _e('Today\'s date', 'genesis'); ?> </option> <option value="rss"<?php selected($this->get_field_value('nav_extras'), 'rss'); ?> ><?php _e('RSS feed links', 'genesis'); ?> </option> <option value="search"<?php selected($this->get_field_value('nav_extras'), 'search'); ?> ><?php _e('Search form', 'genesis'); ?> </option> <option value="twitter"<?php selected($this->get_field_value('nav_extras'), 'twitter'); ?> ><?php _e('Twitter link', 'genesis'); ?> </option> </select> </p> <div id="genesis_nav_extras_twitter"> <p> <label for="<?php echo $this->get_field_id('nav_extras_twitter_id'); ?> "><?php _e('Enter Twitter ID:', 'genesis'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('nav_extras_twitter_id'); ?> " id="<?php echo $this->get_field_id('nav_extras_twitter_id'); ?> " value="<?php echo esc_attr($this->get_field_value('nav_extras_twitter_id')); ?> " size="27" /> </p> <p> <label for="<?php echo $this->get_field_id('nav_extras_twitter_text'); ?> "><?php _e('Twitter Link Text:', 'genesis'); ?> </label> <input type="text" name="<?php echo $this->get_field_name('nav_extras_twitter_text'); ?> " id="<?php echo $this->get_field_id('nav_extras_twitter_text'); ?> " value="<?php echo esc_attr($this->get_field_value('nav_extras_twitter_text')); ?> " size="27" /> </p> </div> </div> </div> <hr class="div" /> <?php } ?> <?php if (genesis_nav_menu_supported('secondary')) { ?> <h4><?php _e('Secondary Navigation', 'genesis'); ?> </h4> <p> <input type="checkbox" name="<?php echo $this->get_field_name('subnav'); ?> " id="<?php echo $this->get_field_id('subnav'); ?> " value="1"<?php checked($this->get_field_value('subnav')); ?> /> <label for="<?php echo $this->get_field_id('subnav'); ?> "><?php _e('Include Secondary Navigation Menu?', 'genesis'); ?> </label> </p> <div id="genesis_subnav_settings"> <p> <input type="checkbox" name="<?php echo $this->get_field_name('subnav_superfish'); ?> " id="<?php echo $this->get_field_id('subnav_superfish'); ?> " value="1"<?php checked($this->get_field_value('subnav_superfish')); ?> /> <label for="<?php echo $this->get_field_id('subnav_superfish'); ?> "><?php _e('Enable Fancy Dropdowns?', 'genesis'); ?> </label> </p> </div> <hr class="div" /> <?php } ?> <p><span class="description"><?php printf(__('In order to use the navigation menus, you must build a <a href="%s">custom menu</a>, then assign it to the proper Menu Location.', 'genesis'), admin_url('nav-menus.php')); ?> </span></p> <?php }
/** * 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)); }
/** * Outputs the Cuttz footer menu. * @return none * @since 1.0 */ function cuttz_do_nav_footer() { if (!genesis_nav_menu_supported('footer_menu')) { return; } if (has_nav_menu('footer_menu')) { $class = 'menu cuttz-menu-footer'; if (genesis_superfish_enabled()) { $class .= ' js-superfish'; } $args = array('theme_location' => 'footer_menu', 'container' => '', '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="cuttz-nav-footer menu">', 'context' => 'cuttz-nav-footer', 'echo' => false)); $nav_markup_close = genesis_html5() ? '</nav>' : '</div>'; $nav_output = $nav_markup_open . $nav . $nav_markup_close; echo apply_filters('cuttz_do_nav_footer', $nav_output, $nav, $args); } }