Make WordPress Core

Ticket #47851: 47851.diff

File 47851.diff, 1.9 KB (added by SergeyBiryukov, 4 years ago)
  • src/wp-admin/users.php

     
    234234                        $userids = array_map( 'intval', (array) $_REQUEST['users'] );
    235235                }
    236236
     237                if ( in_array( $current_user->ID, $userids ) ) {
     238                        $all_userids = $userids;
     239                        $userids     = array_diff( $userids, array( $current_user->ID ) );
     240                }
     241
    237242                /**
    238243                 * Filters whether the users being deleted have additional content
    239244                 * associated with them outside of the `post_author` and `link_owner` relationships.
     
    245250                 */
    246251                $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
    247252
    248                 if ( ! $users_have_content ) {
     253                if ( $userids && ! $users_have_content ) {
    249254                        if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    250255                                $users_have_content = true;
    251256                        } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
     
    271276        </div>
    272277                <?php endif; ?>
    273278
    274                 <?php if ( 1 == count( $userids ) ) : ?>
     279                <?php if ( 1 == count( $all_userids ) ) : ?>
    275280        <p><?php _e( 'You have specified this user for deletion:' ); ?></p>
    276281                <?php else : ?>
    277282        <p><?php _e( 'You have specified these users for deletion:' ); ?></p>
     
    280285<ul>
    281286                <?php
    282287                $go_delete = 0;
    283                 foreach ( $userids as $id ) {
     288                foreach ( $all_userids as $id ) {
    284289                        $user = get_userdata( $id );
    285290                        if ( $id == $current_user->ID ) {
    286291                                /* translators: 1: user id, 2: user login */
     
    314319                                wp_dropdown_users(
    315320                                        array(
    316321                                                'name'    => 'reassign_user',
    317                                                 'exclude' => array_diff( $userids, array( $current_user->ID ) ),
     322                                                'exclude' => $userids,
    318323                                                'show'    => 'display_name_with_login',
    319324                                        )
    320325                                );