From 2d86f12b6f843a0606806c33c31dbfc89f6a1ac4 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 24 Feb 2010 06:41:35 +0000 Subject: [PATCH] Return menu object from wp_create_nav_menu(). Fix trailing separator in menu list. Disable menu delete because it deletes the current menu when a new menu is added. see #11817 git-svn-id: https://develop.svn.wordpress.org/trunk@13362 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/custom-navigation.php | 21 +++++++++++---------- wp-includes/custom-navigation.php | 6 +++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/wp-admin/custom-navigation.php b/wp-admin/custom-navigation.php index f790abb8d8..a302fc6dbb 100644 --- a/wp-admin/custom-navigation.php +++ b/wp-admin/custom-navigation.php @@ -54,8 +54,9 @@ if ( isset( $_POST[ 'delete_menu' ] ) && $menu_selected_id > 0 ) { $menu_selected_id = 0; $updated = true; } + // Default Menu to show -$custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); +$custom_menus = wp_get_nav_menus(); if ( ! $menu_selected_id && ! empty( $custom_menus ) ) $menu_selected_id = $custom_menus[0]->term_id; @@ -174,18 +175,19 @@ if ( isset($_POST['reset_wp_menu']) && ! $updated ) {

@@ -233,8 +235,7 @@ if ( isset($_POST['reset_wp_menu']) && ! $updated ) { - - +

diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php index 188c5b7473..21cf6e047d 100644 --- a/wp-includes/custom-navigation.php +++ b/wp-includes/custom-navigation.php @@ -46,7 +46,11 @@ function wp_create_nav_menu( $menu_name ) { if ( $menu_exists ) return WP_Error('menu_exists', sprintf( __('A menu named "%s" already exists; please try another name.'), $menu_exists->name )); - return wp_insert_term( $menu_name, 'nav_menu' ); + $menu = wp_insert_term( $menu_name, 'nav_menu' ); + if ( is_wp_error($menu) ) + return $menu; + + return get_term( $menu['term_id'], 'nav_menu'); } function wp_get_nav_menu( $menu ) {