From 10d898ecbb8daa10ea9e583487700317359aff25 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 4 Apr 2013 04:28:12 +0000 Subject: [PATCH] Remove _wp_delete_nav_menu(). wp_delete_nav_menu() should instead remove the menu from theme locations, which was the only difference between the functions. see #23119. git-svn-id: http://core.svn.wordpress.org/trunk@23897 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/nav-menu.php | 30 ------------------------------ wp-admin/nav-menus.php | 4 ++-- wp-includes/nav-menu.php | 8 ++++++++ 3 files changed, 10 insertions(+), 32 deletions(-) diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php index 82942ce5c4..4ab33ff016 100644 --- a/wp-admin/includes/nav-menu.php +++ b/wp-admin/includes/nav-menu.php @@ -1205,36 +1205,6 @@ function _wp_delete_orphaned_draft_menu_items() { } add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); -/** - * Delete nav menus from the nav menu management screen - * - * @since 3.6.0 - * @access private - * - * @param int|string $nav_menu_id The menu to delete (id, slug, or name) - * @return false if Error, otherwise true - */ -function _wp_delete_nav_menu( $nav_menu_id ) { - - if ( ! is_nav_menu( $nav_menu_id ) ) - return; - - $deleted_nav_menu = wp_get_nav_menu_object( $nav_menu_id ); - $delete_nav_menu = wp_delete_nav_menu( $nav_menu_id ); - - if ( is_wp_error( $delete_nav_menu ) ) - return $delete_nav_menu; - - // Remove this menu from any locations. - $locations = get_theme_mod( 'nav_menu_locations' ); - foreach ( (array) $locations as $location => $menu_id ) { - if ( $menu_id == $nav_menu_id ) - $locations[ $location ] = 0; - } - set_theme_mod( 'nav_menu_locations', $locations ); - return true; -} - /** * Saves nav menu items * diff --git a/wp-admin/nav-menus.php b/wp-admin/nav-menus.php index 12f46aef2b..9333e5581e 100644 --- a/wp-admin/nav-menus.php +++ b/wp-admin/nav-menus.php @@ -231,7 +231,7 @@ switch ( $action ) { case 'delete': check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); if ( is_nav_menu( $nav_menu_selected_id ) ) { - $deletion = _wp_delete_nav_menu( $nav_menu_selected_id ); + $deletion = wp_delete_nav_menu( $nav_menu_selected_id ); } else { // Reset the selected menu $nav_menu_selected_id = 0; @@ -253,7 +253,7 @@ switch ( $action ) { if ( ! is_nav_menu( $menu_id_to_delete ) ) continue; - $deletion = _wp_delete_nav_menu( $menu_id_to_delete ); + $deletion = wp_delete_nav_menu( $menu_id_to_delete ); if ( is_wp_error( $deletion ) ) { $messages[] = '

' . $deletion->get_error_message() . '

'; $deletion_error = true; diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index aadbe5e461..0aba063884 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -189,6 +189,14 @@ function wp_delete_nav_menu( $menu ) { $result = wp_delete_term( $menu->term_id, 'nav_menu' ); + // Remove this menu from any locations. + $locations = get_theme_mod( 'nav_menu_locations' ); + foreach ( (array) $locations as $location => $menu_id ) { + if ( $menu_id == $nav_menu_id ) + $locations[ $location ] = 0; + } + set_theme_mod( 'nav_menu_locations', $locations ); + if ( $result && !is_wp_error($result) ) do_action( 'wp_delete_nav_menu', $menu->term_id );