From: Ian Weller Date: Thu, 13 Nov 2014 17:17:00 +0000 (-0500) Subject: adding nav menu X-Git-Tag: v1.0.0~85 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=82cabc65a0325952d6eb448ac36e724cde2ac633;p=WP-Themes%2FPrestonFeather.git adding nav menu --- diff --git a/functions.php b/functions.php index 12d4aea..18b3851 100755 --- a/functions.php +++ b/functions.php @@ -3,5 +3,29 @@ function register_my_menu() { register_nav_menu('header-menu',__( 'Header Menu' )); } add_action( 'init', 'register_my_menu' ); +/** + * Left top bar + * http://codex.wordpress.org/Function_Reference/wp_nav_menu + */ +if ( ! function_exists( 'foundationPress_top_bar_l' ) ) { + function foundationPress_top_bar_l() { + wp_nav_menu(array( + 'container' => false, // remove nav container + 'container_class' => '', // class of container + 'menu' => '', // menu name + 'menu_class' => 'top-bar-menu left', // adding custom nav class + 'theme_location' => 'top-bar-l', // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 5, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new top_bar_walker() + )); + } +} +// Add menu walker +require_once('library/top-bar_walker.php'); ?> \ No newline at end of file diff --git a/header.php b/header.php index 66a6ea5..60a16ce 100644 --- a/header.php +++ b/header.php @@ -39,14 +39,8 @@
@@ -78,19 +72,4 @@ -
-
-
- -
-

Kitchen & Bath

-

sam nos si dessus aciendes nis nos si deaciendes.

-
-
-
-
-
-

Helping You Build With Confidence Since 1915

-
-
-
+ diff --git a/library/navigation.php b/library/navigation.php new file mode 100644 index 0000000..05aff31 --- /dev/null +++ b/library/navigation.php @@ -0,0 +1,98 @@ + 'Left Top Bar', // registers the menu in the WordPress admin menu editor + 'top-bar-r' => 'Right Top Bar', + 'mobile-off-canvas' => 'Mobile' +)); + + +/** + * Left top bar + * http://codex.wordpress.org/Function_Reference/wp_nav_menu + */ +if ( ! function_exists( 'foundationPress_top_bar_l' ) ) { + function foundationPress_top_bar_l() { + wp_nav_menu(array( + 'container' => false, // remove nav container + 'container_class' => '', // class of container + 'menu' => '', // menu name + 'menu_class' => 'top-bar-menu left', // adding custom nav class + 'theme_location' => 'top-bar-l', // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 5, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new top_bar_walker() + )); + } +} + +/** + * Right top bar + */ +if ( ! function_exists( 'foundationPress_top_bar_r' ) ) { + function foundationPress_top_bar_r() { + wp_nav_menu(array( + 'container' => false, // remove nav container + 'container_class' => '', // class of container + 'menu' => '', // menu name + 'menu_class' => 'top-bar-menu right', // adding custom nav class + 'theme_location' => 'top-bar-r', // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 5, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new top_bar_walker() + )); + } +} + +/** + * Mobile off-canvas + */ +if ( ! function_exists( 'foundationPress_mobile_off_canvas' ) ) { + function foundationPress_mobile_off_canvas() { + wp_nav_menu(array( + 'container' => false, // remove nav container + 'container_class' => '', // class of container + 'menu' => '', // menu name + 'menu_class' => 'off-canvas-list', // adding custom nav class + 'theme_location' => 'mobile-off-canvas', // where it's located in the theme + 'before' => '', // before each link + 'after' => '', // after each link + 'link_before' => '', // before each link text + 'link_after' => '', // after each link text + 'depth' => 5, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new top_bar_walker() + )); + } +} + +/** + * Add support for buttons in the top-bar menu: + * 1) In WordPress admin, go to Apperance -> Menus. + * 2) Click 'Screen Options' from the top panel and enable 'CSS CLasses' and 'Link Relationship (XFN)' + * 3) On your menu item, type 'has-form' in the CSS-classes field. Type 'button' in the XFN field + * 4) Save Menu. Your menu item will now appear as a button in your top-menu +*/ +if ( ! function_exists( 'add_menuclass') ) { + function add_menuclass($ulclass) { + $find = array('/ diff --git a/library/top-bar_walker.php b/library/top-bar_walker.php new file mode 100644 index 0000000..8218dd5 --- /dev/null +++ b/library/top-bar_walker.php @@ -0,0 +1,41 @@ +has_children = !empty( $children_elements[$element->ID] ); + $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : ''; + $element->classes[] = ( $element->has_children && $max_depth !== 1 ) ? 'has-dropdown' : ''; + + parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output ); + } + + function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) { + $item_html = ''; + parent::start_el( $item_html, $object, $depth, $args ); + + $output .= ( $depth == 0 ) ? '
  • ' : ''; + + $classes = empty( $object->classes ) ? array() : (array) $object->classes; + + if( in_array('label', $classes) ) { + $output .= '
  • '; + $item_html = preg_replace( '/]*>(.*)<\/a>/iU', '', $item_html ); + } + + if ( in_array('divider', $classes) ) { + $item_html = preg_replace( '/]*>( .* )<\/a>/iU', '', $item_html ); + } + + $output .= $item_html; + } + + function start_lvl( &$output, $depth = 0, $args = array() ) { + $output .= "\n
      \n"; + } + +} +?> \ No newline at end of file