Ticket #16358: 16358-no-nav_menu_item.diff

File 16358-no-nav_menu_item.diff, 860 bytes (added by nacin, 2 years ago)
Line 
1Index: wp-admin/includes/user.php
2===================================================================
3--- wp-admin/includes/user.php  (revision 17347)
4+++ wp-admin/includes/user.php  (working copy)
5@@ -278,7 +278,10 @@
6        do_action('delete_user', $id);
7 
8        if ( 'novalue' === $reassign || null === $reassign ) {
9-               $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
10+               $post_types_to_not_delete = apply_filters( 'delete_user_not_these_post_types', array( 'nav_menu_item' ), $id );
11+               $post_types = array_diff( get_post_types(), $post_types_to_not_delete );
12+               $post_types = implode( "', '", $post_types );
13+               $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types')", $id) );
14 
15                if ( $post_ids ) {
16                        foreach ( $post_ids as $post_id )