From 7915dbb80afc681637621e2944b2da4b71d36c65 Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Tue, 23 Feb 2010 03:19:30 +0000 Subject: [PATCH] add function for deleting individual menus, see #11817 git-svn-id: https://develop.svn.wordpress.org/trunk@13322 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/custom-navigation.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/wp-includes/custom-navigation.php b/wp-includes/custom-navigation.php index 37b7e47aed..d927fd47d4 100644 --- a/wp-includes/custom-navigation.php +++ b/wp-includes/custom-navigation.php @@ -40,16 +40,22 @@ function wp_custom_navigation_setup($override = false) { $custom_menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) ); if ( !empty( $custom_menus ) ) { foreach ( $custom_menus as $menu ) { - $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' ); - if ( !empty( $menu_objects ) ) { - foreach ( $menu_objects as $item ) { - wp_delete_post( $item ); - } - } - wp_delete_term( $menu->term_id, 'nav_menu' ); + wp_custom_navigation_delete_menu( $menu->term_id ); } } } +function wp_custom_navigation_delete_menu( $menu_term_id ) { + $term_id = (int) $menu_term_id; + if ( $term_id > 0 ) { + $menu_objects = get_objects_in_term( $term_id, 'nav_menu' ); + if ( !empty( $menu_objects ) ) { + foreach ( $menu_objects as $item ) { + wp_delete_post( $item ); + } + } + wp_delete_term( $term_id, 'nav_menu' ); + } +} /*-----------------------------------------------------------------------------------*/ /* Custom Navigation Functions */