add function for deleting individual menus, see #11817

git-svn-id: https://develop.svn.wordpress.org/trunk@13322 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ron Rennick 2010-02-23 03:19:30 +00:00
parent 2e25b92eb2
commit 7915dbb80a
1 changed files with 13 additions and 7 deletions

View File

@ -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 */