WordPress.org

Make WordPress Core

Changeset 13322


Ignore:
Timestamp:
02/23/10 03:19:30 (4 years ago)
Author:
wpmuguru
Message:

add function for deleting individual menus, see #11817

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/custom-navigation.php

    r13318 r13322  
    4141    if ( !empty( $custom_menus ) ) { 
    4242        foreach ( $custom_menus as $menu ) { 
    43             $menu_objects = get_objects_in_term( $menu->term_id, 'nav_menu' ); 
    44             if ( !empty( $menu_objects ) ) { 
    45                 foreach ( $menu_objects as $item ) { 
    46                     wp_delete_post( $item ); 
    47                 } 
    48             } 
    49             wp_delete_term( $menu->term_id, 'nav_menu' ); 
     43            wp_custom_navigation_delete_menu( $menu->term_id ); 
    5044        } 
     45    } 
     46} 
     47function wp_custom_navigation_delete_menu( $menu_term_id ) { 
     48    $term_id = (int) $menu_term_id; 
     49    if ( $term_id > 0 ) { 
     50        $menu_objects = get_objects_in_term( $term_id, 'nav_menu' ); 
     51        if ( !empty( $menu_objects ) ) { 
     52            foreach ( $menu_objects as $item ) { 
     53                wp_delete_post( $item ); 
     54            } 
     55        } 
     56        wp_delete_term( $term_id, 'nav_menu' ); 
    5157    } 
    5258} 
Note: See TracChangeset for help on using the changeset viewer.