Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Enable third level of menu items.

Update release notes
  • Loading branch information...
commit 6b68c10efb989bf5154849e23b30aaede59d4de8 1 parent db68aa5
@obenland authored
Showing with 118 additions and 109 deletions.
  1. +1 −1  footer.php
  2. +2 −2 header.php
  3. +104 −104 inc/nav-menu-walker.php
  4. +11 −2 readme.txt
View
2  footer.php
@@ -15,7 +15,7 @@
'container_class' => 'subnav',
'theme_location' => 'footer-menu',
'menu_class' => 'credits nav nav-pills pull-left',
- 'depth' => 2,
+ 'depth' => 3,
'fallback_cb' => 'the_bootstrap_credits',
'walker' => new The_Bootstrap_Nav_Walker,
) );
View
4 header.php
@@ -34,7 +34,7 @@
'container_class' => 'subnav clearfix',
'theme_location' => 'header-menu',
'menu_class' => 'nav nav-pills pull-right',
- 'depth' => 2,
+ 'depth' => 3,
'fallback_cb' => false,
'walker' => new The_Bootstrap_Nav_Walker,
) ); ?>
@@ -74,7 +74,7 @@
<?php wp_nav_menu( array(
'theme_location' => 'primary',
'menu_class' => 'nav',
- 'depth' => 2,
+ 'depth' => 3,
'fallback_cb' => 'the_bootstrap_main_menu_fallback',
'walker' => new The_Bootstrap_Nav_Walker,
) );
View
208 inc/nav-menu-walker.php
@@ -1,125 +1,125 @@
<?php
-/** nav-menu-walker.php
- *
- * @author Konstantin Obenland
- * @package The Bootstrap
- * @since 1.5.0 - 15.05.2012
+/** nav-menu-walker.php
+ *
+ * @author Konstantin Obenland
+ * @package The Bootstrap
+ * @since 1.5.0 - 15.05.2012
*/
-class The_Bootstrap_Nav_Walker extends Walker_Nav_Menu {
+class The_Bootstrap_Nav_Walker extends Walker_Nav_Menu {
/**
* @see Walker_Nav_Menu::start_lvl()
- */
- function start_lvl( &$output, $depth ) {
- $output .= "\n<ul class=\"dropdown-menu\">\n";
- }
+ */
+ function start_lvl( &$output, $depth ) {
+ $output .= "\n<ul class=\"dropdown-menu\">\n";
+ }
/**
* @see Walker_Nav_Menu::start_el()
- */
- function start_el( &$output, $item, $depth, $args ) {
- global $wp_query;
+ */
+ function start_el( &$output, $item, $depth, $args ) {
+ global $wp_query;
- $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
- $li_attributes = $class_names = $value = '';
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $classes[] = 'menu-item-' . $item->ID;
-
- if ( $args->has_children ) {
- $classes[] = 'dropdown';
- $li_attributes .= ' data-dropdown="dropdown"';
- }
-
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
- $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
-
- $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
- $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
-
- $output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
-
- $attributes = $item->attr_title ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= $item->target ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= $item->xfn ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= $item->url ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $attributes .= $args->has_children ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
-
- $item_output = $args->before . '<a' . $attributes . '>';
- $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
- $item_output .= ( $args->has_children ) ? ' <b class="caret"></b>' : '';
- $item_output .= '</a>' . $args->after;
-
- $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
- }
+ $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
+ $li_attributes = $class_names = $value = '';
+ $classes = empty( $item->classes ) ? array() : (array) $item->classes;
+ $classes[] = 'menu-item-' . $item->ID;
+
+ if ( $args->has_children ) {
+ $classes[] = ( 1 > $depth) ? 'dropdown': 'dropdown-submenu';
+ $li_attributes .= ' data-dropdown="dropdown"';
+ }
+
+ $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
+ $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
+
+ $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
+ $id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
+
+ $output .= $indent . '<li' . $id . $value . $class_names . $li_attributes . '>';
+
+ $attributes = $item->attr_title ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
+ $attributes .= $item->target ? ' target="' . esc_attr( $item->target ) .'"' : '';
+ $attributes .= $item->xfn ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
+ $attributes .= $item->url ? ' href="' . esc_attr( $item->url ) .'"' : '';
+ $attributes .= $args->has_children ? ' class="dropdown-toggle" data-toggle="dropdown"' : '';
+
+ $item_output = $args->before . '<a' . $attributes . '>';
+ $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
+ $item_output .= ( $args->has_children AND 1 > $depth ) ? ' <b class="caret"></b>' : '';
+ $item_output .= '</a>' . $args->after;
+
+ $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
+ }
/**
* @see Walker::display_element()
- */
- function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
-
- if ( ! $element )
- return;
-
- $id_field = $this->db_fields['id'];
-
- //display this element
- if ( is_array( $args[0] ) )
- $args[0]['has_children'] = (bool) ( ! empty( $children_elements[$element->$id_field] ) AND $depth != $max_depth - 1 );
- elseif ( is_object( $args[0] ) )
- $args[0]->has_children = (bool) ( ! empty( $children_elements[$element->$id_field] ) AND $depth != $max_depth - 1 );
-
- $cb_args = array_merge( array( &$output, $element, $depth ), $args );
- call_user_func_array( array( &$this, 'start_el' ), $cb_args );
-
- $id = $element->$id_field;
-
- // descend only when the depth is right and there are childrens for this element
- if ( ( $max_depth == 0 OR $max_depth > $depth+1 ) AND isset( $children_elements[$id] ) ) {
-
- foreach ( $children_elements[ $id ] as $child ) {
-
- if ( ! isset( $newlevel ) ) {
- $newlevel = true;
- //start the child delimiter
- $cb_args = array_merge( array( &$output, $depth ), $args );
- call_user_func_array( array( &$this, 'start_lvl' ), $cb_args );
- }
- $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
- }
- unset( $children_elements[ $id ] );
- }
-
- if ( isset( $newlevel ) AND $newlevel ) {
- //end the child delimiter
- $cb_args = array_merge( array( &$output, $depth ), $args );
- call_user_func_array( array( &$this, 'end_lvl' ), $cb_args );
- }
-
- //end this element
- $cb_args = array_merge( array( &$output, $element, $depth ), $args );
- call_user_func_array( array( &$this, 'end_el' ), $cb_args );
- }
+ */
+ function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
+
+ if ( ! $element )
+ return;
+
+ $id_field = $this->db_fields['id'];
+
+ //display this element
+ if ( is_array( $args[0] ) )
+ $args[0]['has_children'] = (bool) ( ! empty( $children_elements[$element->$id_field] ) AND $depth != $max_depth - 1 );
+ elseif ( is_object( $args[0] ) )
+ $args[0]->has_children = (bool) ( ! empty( $children_elements[$element->$id_field] ) AND $depth != $max_depth - 1 );
+
+ $cb_args = array_merge( array( &$output, $element, $depth ), $args );
+ call_user_func_array( array( &$this, 'start_el' ), $cb_args );
+
+ $id = $element->$id_field;
+
+ // descend only when the depth is right and there are childrens for this element
+ if ( ( $max_depth == 0 OR $max_depth > $depth+1 ) AND isset( $children_elements[$id] ) ) {
+
+ foreach ( $children_elements[ $id ] as $child ) {
+
+ if ( ! isset( $newlevel ) ) {
+ $newlevel = true;
+ //start the child delimiter
+ $cb_args = array_merge( array( &$output, $depth ), $args );
+ call_user_func_array( array( &$this, 'start_lvl' ), $cb_args );
+ }
+ $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
+ }
+ unset( $children_elements[ $id ] );
+ }
+
+ if ( isset( $newlevel ) AND $newlevel ) {
+ //end the child delimiter
+ $cb_args = array_merge( array( &$output, $depth ), $args );
+ call_user_func_array( array( &$this, 'end_lvl' ), $cb_args );
+ }
+
+ //end this element
+ $cb_args = array_merge( array( &$output, $element, $depth ), $args );
+ call_user_func_array( array( &$this, 'end_el' ), $cb_args );
+ }
}
/**
- * Adds the active CSS class
- *
- * @author Konstantin Obenland
- * @since 1.5.0 - 15.05.2012
- *
- * @param array $classes Default class names
- *
- * @return array
- */
-function the_bootstrap_nav_menu_css_class( $classes ) {
- if ( in_array('current-menu-item', $classes ) OR in_array( 'current-menu-ancestor', $classes ) )
- $classes[] = 'active';
-
- return $classes;
-}
+ * Adds the active CSS class
+ *
+ * @author Konstantin Obenland
+ * @since 1.5.0 - 15.05.2012
+ *
+ * @param array $classes Default class names
+ *
+ * @return array
+ */
+function the_bootstrap_nav_menu_css_class( $classes ) {
+ if ( in_array('current-menu-item', $classes ) OR in_array( 'current-menu-ancestor', $classes ) )
+ $classes[] = 'active';
+
+ return $classes;
+}
add_filter( 'nav_menu_css_class', 'the_bootstrap_nav_menu_css_class' );
View
13 readme.txt
@@ -16,8 +16,8 @@ The Bootstrap is fully compatible with WordPress SEO by Yoast!
Please note:
-Due to design restrictions in Bootstrap, the navigation menu can only be two levels deep, while parent menu items only serves as a headline for the child menu items and can not be accessed over the navigation menu.
-The Footer Menu is best suitable for short menues with just a few links. It replaces the credits section, once a menu has been assigned to the location. It will hold only top level nav items.
+Due to design restrictions in Bootstrap, the navigation menu can "only" be three levels deep, while parent menu items only serves as a headline for the child menu items and can not be accessed over the navigation menu.
+The Footer Menu is best suitable for short menues with just a few links. It replaces the credits section, once a menu has been assigned to the location.
To take advantage of all the possibilites Bootstrap has to offer, Bootstrap requires jQuery 1.7, which does not come with WordPress versions prior to 3.3.0. Consider adding a plugin that provides the lates version of jQuery, if you want to use this Theme with WordPress 3.2.1 or lower.
= License =
@@ -72,10 +72,19 @@ For more information on SemVer, please visit [http://semver.org/].
THIS IS A MAJOR RELEASE, BREAKING BACKWARD COMPATIBILITY IN SOME PLACES
+* Theme Options will only be available for outdated WordPress versions and will be removed in the future. Going Customizer all the way!
* Updated Twitter Bootstrap to 2.1
* Updated Russian translation to fix a bug in the carousel navigation
* Added French translation. Props Narine
+* Navbar menues now support a third level of menu items
+* Nav-pill menues now also support a second and third level of menu items
+* Improved support for all possible amounts of gallery columns, limiting at eight
* Improved pagination to handle query strings better
+* Twitter status embeds are now responsive, too. Props @kovshenin
+* Now only shows category and tags when there are any, pending core implementation
+* Fixed undefined variable notice in image.php
+* Order of words in image navigation can now be localized
+* Various other small improvements
= 1.8.2 =
* Added missing classname change to style.min.css
Please sign in to comment.
Something went wrong with that request. Please try again.