Index: /trunk/wp-includes/custom-navigation.php
===================================================================
--- /trunk/wp-includes/custom-navigation.php (revision 13292)
+++ /trunk/wp-includes/custom-navigation.php (revision 13293)
@@ -117,7 +117,8 @@
$parent_stack = array();
+ $current_parent = 0;
$parent_menu_order = array();
// Display Loop
- foreach ( $menu_items as $menu_item ) {
+ foreach ( $menu_items as $key => $menu_item ) {
$menu_type = get_post_meta($menu_item->ID, 'menu_type', true);
$object_id = get_post_meta($menu_item->ID, 'object_id', true);
@@ -200,29 +201,4 @@
}
*/
- // Indent children
- if ( empty( $parent_stack ) ) {
- array_unshift( $parent_stack, $menu_item->ID );
- } elseif ( $menu_item->post_parent > 0 ) {
- if ( $menu_item->post_parent == $parent_stack[0] ) { ?>
-
-ID );
- } elseif ( count( $parent_stack ) > 1 && $menu_item->post_parent == $parent_stack[1] ) { ?>
-
-ID;
- } elseif ( in_array( $menu_item->post_parent, $parent_stack ) ) {
- while ( !empty( $parent_stack ) && $menu_item->post_parent != $parent_stack[0] ) { ?>
-
- array_shift( $parent_stack );
- }
- }
- } else {
- while ( count( $parent_stack ) > 1 ) { ?>
-
- array_shift( $parent_stack );
- } ?>
-
-ID;
- }
-
// List Items
?>
- array_shift( $parent_stack );
- }
- if ( !empty( $menu_items ) ) { ?>
+ // Indent children
+ $last_item = ( count( $menu_items ) == $menu_item->menu_order );
+ if ( $last_item || $current_parent != $menu_items[ $key + 1 ]->post_parent ) {
+ if ( $last_item || in_array( $menu_items[ $key + 1 ]->post_parent, $parent_stack ) ) { ?>
-post_parent != $current_parent ) ) { ?>
+
+
+ $current_parent = array_pop( $parent_stack );
+ } ?>
+ID; ?>
+