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
This commit is contained in:
Andrew Nacin 2013-04-04 04:28:12 +00:00
parent 8fdaa65f91
commit 10d898ecbb
3 changed files with 10 additions and 32 deletions

View File

@ -1205,36 +1205,6 @@ function _wp_delete_orphaned_draft_menu_items() {
} }
add_action('admin_head-nav-menus.php', '_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 * Saves nav menu items
* *

View File

@ -231,7 +231,7 @@ switch ( $action ) {
case 'delete': case 'delete':
check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id ); check_admin_referer( 'delete-nav_menu-' . $nav_menu_selected_id );
if ( is_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 { } else {
// Reset the selected menu // Reset the selected menu
$nav_menu_selected_id = 0; $nav_menu_selected_id = 0;
@ -253,7 +253,7 @@ switch ( $action ) {
if ( ! is_nav_menu( $menu_id_to_delete ) ) if ( ! is_nav_menu( $menu_id_to_delete ) )
continue; continue;
$deletion = _wp_delete_nav_menu( $menu_id_to_delete ); $deletion = wp_delete_nav_menu( $menu_id_to_delete );
if ( is_wp_error( $deletion ) ) { if ( is_wp_error( $deletion ) ) {
$messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>'; $messages[] = '<div id="message" class="error"><p>' . $deletion->get_error_message() . '</p></div>';
$deletion_error = true; $deletion_error = true;

View File

@ -189,6 +189,14 @@ function wp_delete_nav_menu( $menu ) {
$result = wp_delete_term( $menu->term_id, 'nav_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) ) if ( $result && !is_wp_error($result) )
do_action( 'wp_delete_nav_menu', $menu->term_id ); do_action( 'wp_delete_nav_menu', $menu->term_id );