add function for deleting individual menus, see #11817

git-svn-id: http://svn.automattic.com/wordpress/trunk@13322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
wpmuguru 2010-02-23 03:19:30 +00:00
parent d91b382e1f
commit 955e9e7527

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