Make WordPress Core

Ticket #34993: 34993.patch

File 34993.patch, 1.0 KB (added by swissspidy, 9 years ago)
  • src/wp-admin/users.php

    diff --git src/wp-admin/users.php src/wp-admin/users.php
    index 44d860e..69812d4 100644
    case 'delete': 
    211211        else
    212212                $userids = array_map( 'intval', (array) $_REQUEST['users'] );
    213213
    214         $users_posts = new WP_Query( array(
    215                 'post_type' => 'any',
    216                 'author' => implode( ',', $userids ),
    217                 'posts_per_page' => 1
    218         ) );
     214        global $wpdb;
     215
     216        $users_posts = $wpdb->get_results(
     217                "SELECT post_author, COUNT(*) as post_count
     218                        FROM $wpdb->posts
     219                        WHERE post_author IN ( " . implode( ',', $userids ) . "  )
     220                        AND post_status = 'publish' OR post_status = 'private'
     221                        GROUP BY post_author"
     222        );
    219223
    220         if ( $users_posts->have_posts() ) {
     224        if ( ! empty( $users_posts ) ) {
    221225                add_action( 'admin_head', 'delete_users_add_js' );
    222226        }
    223227
    case 'delete': 
    257261        </ul>
    258262<?php if ( $go_delete ) :
    259263
    260         if ( ! $users_posts->have_posts() ) : ?>
     264        if ( empty( $users_posts ) ) : ?>
    261265                <input type="hidden" name="delete_option" value="delete" />
    262266        <?php else: ?>
    263267                <?php if ( 1 == $go_delete ) : ?>