WordPress.org

Make WordPress Core

Ticket #15264: 15264.2.diff

File 15264.2.diff, 2.4 KB (added by SergeyBiryukov, 15 months ago)

Same as 15264.diff, with a minor formatting fix

  • wp-includes/default-filters.php

     
    261261 
    262262// Navigation menu actions 
    263263add_action( 'delete_post',                '_wp_delete_post_menu_item'         ); 
    264 add_action( 'delete_term',                '_wp_delete_tax_menu_item'          ); 
     264add_action( 'delete_term',                '_wp_delete_tax_menu_item',   10, 3 ); 
    265265add_action( 'transition_post_status',     '_wp_auto_add_pages_to_menu', 10, 3 ); 
    266266 
    267267// Post Thumbnail CSS class filtering 
  • wp-includes/nav-menu.php

     
    674674 * 
    675675 * @param int $object_id The ID of the original object. 
    676676 * @param string $object_type The type of object, such as "taxonomy" or "post_type." 
     677 * @param string $taxonomy If $object_type is "taxonomy", $taxonomy is the name of the tax that $object_id belongs to 
    677678 * @return array The array of menu item IDs; empty array if none; 
    678679 */ 
    679 function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type' ) { 
     680function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' ) { 
    680681        $object_id = (int) $object_id; 
    681682        $menu_item_ids = array(); 
    682683 
     
    692693        ); 
    693694        foreach( (array) $menu_items as $menu_item ) { 
    694695                if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) { 
    695                         if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) != $object_type ) 
     696                        if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) !== $object_type || 
     697                                get_post_meta( $menu_item->ID, '_menu_item_object', true ) !== $taxonomy ) 
    696698                                continue; 
    697699 
    698700                        $menu_item_ids[] = (int) $menu_item->ID; 
     
    730732 * @param int $object_id The ID of the original object being trashed. 
    731733 * 
    732734 */ 
    733 function _wp_delete_tax_menu_item( $object_id = 0 ) { 
     735function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) { 
    734736        $object_id = (int) $object_id; 
    735737 
    736         $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy' ); 
     738        $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy ); 
    737739 
    738740        foreach( (array) $menu_item_ids as $menu_item_id ) { 
    739741                wp_delete_post( $menu_item_id, true );