WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/08/2015 10:06:46 PM (5 years ago)
Author:
johnbillion
Message:

Introduce the ability to filter the Users admin listing screen by users with no role, if such users exist.

Fixes #22993
Props spmlucas, johnbillion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-users-list-table.php

    r34963 r34965  
    8888        $paged = $this->get_pagenum();
    8989
    90         $args = array(
    91             'number' => $users_per_page,
    92             'offset' => ( $paged-1 ) * $users_per_page,
    93             'role' => $role,
    94             'search' => $usersearch,
    95             'fields' => 'all_with_meta'
    96         );
     90        if ( 'none' === $role ) {
     91            $args = array(
     92                'number' => $users_per_page,
     93                'offset' => ( $paged-1 ) * $users_per_page,
     94                'include' => wp_get_users_with_no_role(),
     95                'search' => $usersearch,
     96                'fields' => 'all_with_meta'
     97            );
     98        } else {
     99            $args = array(
     100                'number' => $users_per_page,
     101                'offset' => ( $paged-1 ) * $users_per_page,
     102                'role' => $role,
     103                'search' => $usersearch,
     104                'fields' => 'all_with_meta'
     105            );
     106        }
    97107
    98108        if ( '' !== $args['search'] )
     
    167177            $users_of_blog = count_users();
    168178        }
     179
    169180        $total_users = $users_of_blog['total_users'];
    170181        $avail_roles =& $users_of_blog['avail_roles'];
     
    188199            $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
    189200            $role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$class>$name</a>";
     201        }
     202
     203        if ( ! empty( $avail_roles['none' ] ) ) {
     204
     205            $class = '';
     206
     207            if ( 'none' === $role ) {
     208                $class = ' class="current"';
     209            }
     210
     211            $name = __( 'No role' );
     212            /* translators: User role name with count */
     213            $name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
     214            $role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$class>$name</a>";
     215
    190216        }
    191217
Note: See TracChangeset for help on using the changeset viewer.