From e7114b42f9d5fd6df6b1ffa4e9e72ca00cf8c6d5 Mon Sep 17 00:00:00 2001 From: wpmuguru Date: Wed, 24 Feb 2010 00:37:15 +0000 Subject: [PATCH] dont show items when menu empty, See #11817 git-svn-id: http://svn.automattic.com/wordpress/trunk@13354 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/custom-navigation.php | 33 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php index 5dbf666fe1..e989816eec 100644 --- a/wp-includes/custom-navigation.php +++ b/wp-includes/custom-navigation.php @@ -56,26 +56,27 @@ function wp_get_nav_menus() { function wp_get_nav_menu_items( $menu, $args = array() ) { $items = get_objects_in_term( (int) $menu, 'nav_menu' ); - $defaults = array( 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order' ); - $args = wp_parse_args($args, $defaults); - if ( count( $items ) > 1 ) - $args['include'] = implode( ',', $items ); - else - $args['include'] = $items[0]; + if ( ! empty( $items ) ) { + $defaults = array( 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order' ); + $args = wp_parse_args($args, $defaults); + if ( count( $items ) > 1 ) + $args['include'] = implode( ',', $items ); + else + $args['include'] = $items[0]; - $items = get_posts( $args ); + $items = get_posts( $args ); - if ( ARRAY_A == $args['output'] ) { - $output = array(); - foreach ( $items as $item ) { - $output[$item->$args['output_key']] = $item; + if ( ARRAY_A == $args['output'] ) { + $output = array(); + foreach ( $items as $item ) { + $output[$item->$args['output_key']] = $item; + } + unset($items); + ksort($output); + return $output; } - unset($items); - ksort($output); - return $output; - } else { - return $items; } + return $items; } function setup_menu_item($menu_item, $type = 'item', $position = 0) {