WordPress.org

Make WordPress Core

Ticket #15264: garyc40-15264.patch

File garyc40-15264.patch, 2.9 KB (added by garyc40, 7 years ago)

there's a patch for that

  • wp-includes/default-filters.php

    diff --git wp-includes/default-filters.php wp-includes/default-filters.php
    index c796453..4121af3 100644
    add_action( 'comment_form', 'wp_comment_form_unfiltered_html_nonce' ); 
    248248add_action( 'wp_scheduled_delete',        'wp_scheduled_delete'            );
    249249
    250250// Navigation menu actions
    251 add_action( 'delete_post',                '_wp_delete_post_menu_item'      );
    252 add_action( 'delete_term',                '_wp_delete_tax_menu_item'      );
    253 add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu',  10, 3 );
     251add_action( 'delete_post',                '_wp_delete_post_menu_item'       );
     252add_action( 'delete_term',                '_wp_delete_tax_menu_item', 10, 3 );
     253add_action( 'transition_post_status', '_wp_auto_add_pages_to_menu',   10, 3 );
    254254
    255255// Post Thumbnail CSS class filtering
    256256add_action( 'begin_fetch_post_thumbnail_html', '_wp_post_thumbnail_class_filter_add'    );
  • wp-includes/nav-menu.php

    diff --git wp-includes/nav-menu.php wp-includes/nav-menu.php
    index e1af8f7..1a30131 100644
    function wp_setup_nav_menu_item( $menu_item ) { 
    640640 *
    641641 * @param int $object_id The ID of the original object.
    642642 * @param string $object_type The type of object, such as "taxonomy" or "post_type."
     643 * @param string $taxonomy If $object_type is "taxonomy", $taxonomy is the name of the tax that $object_id belongs to
    643644 * @return array The array of menu item IDs; empty array if none;
    644645 */
    645 function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type' ) {
     646function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_type', $taxonomy = '' ) {
    646647        $object_id = (int) $object_id;
    647648        $menu_item_ids = array();
    648649
    function wp_get_associated_nav_menu_items( $object_id = 0, $object_type = 'post_ 
    658659        );
    659660        foreach( (array) $menu_items as $menu_item ) {
    660661                if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) {
    661                         if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) != $object_type )
     662                        if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) != $object_type || get_post_meta( $menu_item->ID, '_menu_item_object', true ) != $taxonomy )
    662663                                continue;
    663664
    664665                        $menu_item_ids[] = (int) $menu_item->ID;
    function _wp_delete_post_menu_item( $object_id = 0 ) { 
    696697 * @param int $object_id The ID of the original object being trashed.
    697698 *
    698699 */
    699 function _wp_delete_tax_menu_item( $object_id = 0 ) {
     700function _wp_delete_tax_menu_item( $object_id = 0, $tt_id, $taxonomy ) {
    700701        $object_id = (int) $object_id;
    701702
    702         $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy' );
     703        $menu_item_ids = wp_get_associated_nav_menu_items( $object_id, 'taxonomy', $taxonomy );
    703704
    704705        foreach( (array) $menu_item_ids as $menu_item_id ) {
    705706                wp_delete_post( $menu_item_id, true );