From 117a68163d7dfd9ddd04d63a08202bc4f13204a7 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Mon, 22 Feb 2010 17:27:34 +0000 Subject: [PATCH] improve custom menu hierarchy logic, See #11817 git-svn-id: https://develop.svn.wordpress.org/trunk@13293 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/custom-navigation.php | 53 ++++++++++++------------------- 1 file changed, 20 insertions(+), 33 deletions(-) diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php index 354d95fd95..8e478774e4 100644 --- a/wp-includes/custom-navigation.php +++ b/wp-includes/custom-navigation.php @@ -116,9 +116,10 @@ function wp_custom_navigation_output($args = array()) { $queried_id = $wp_query->get_queried_object_id(); $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); $parent_menu_order[ $menu_item->ID ] = $menu_item->menu_order; @@ -199,31 +200,6 @@ function wp_custom_navigation_output($args = array()) { } } */ - // 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] ) { ?> - - 1 ) { ?> - - - -ID; - } - // List 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 ) ) { ?> + + + +ID; ?> +