Users: When determining whether to show the reassign content option during user delete, don't rely upon WP_Query as it doesn't return all forms of content wp_delete_user() operates on.

This restores the reassign form when a user has a non-public post type or links assigned to them.

Props swissspidy & tharsheblows for initial patches.
Fixes #34993 for trunk.

Built from https://develop.svn.wordpress.org/trunk@36068


git-svn-id: http://core.svn.wordpress.org/trunk@36033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dion Hulse 2015-12-23 04:46:28 +00:00
parent e7b3d9cd11
commit 04bca9732b
2 changed files with 9 additions and 8 deletions

View File

@ -211,13 +211,14 @@ case 'delete':
else
$userids = array_map( 'intval', (array) $_REQUEST['users'] );
$users_posts = new WP_Query( array(
'post_type' => 'any',
'author' => implode( ',', $userids ),
'posts_per_page' => 1
) );
$users_have_content = false;
if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) {
$users_have_content = true;
} elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) {
$users_have_content = true;
}
if ( $users_posts->have_posts() ) {
if ( $users_have_content ) {
add_action( 'admin_head', 'delete_users_add_js' );
}
@ -257,7 +258,7 @@ case 'delete':
</ul>
<?php if ( $go_delete ) :
if ( ! $users_posts->have_posts() ) : ?>
if ( ! $users_have_content ) : ?>
<input type="hidden" name="delete_option" value="delete" />
<?php else: ?>
<?php if ( 1 == $go_delete ) : ?>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-36062';
$wp_version = '4.5-alpha-36068';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.