X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..febc815b2c9d85be5717da9e8d164bd2daa97e31:/wp-admin/includes/class-wp-ms-users-list-table.php diff --git a/wp-admin/includes/class-wp-ms-users-list-table.php b/wp-admin/includes/class-wp-ms-users-list-table.php index 36d55e1c..da00131b 100644 --- a/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/wp-admin/includes/class-wp-ms-users-list-table.php @@ -1,22 +1,40 @@ get_items_per_page( 'users_network_per_page' ); @@ -32,16 +50,24 @@ class WP_MS_Users_List_Table extends WP_List_Table { 'fields' => 'all_with_meta' ); - $args['search'] = ltrim($args['search'], '*'); + if ( wp_is_large_network( 'users' ) ) { + $args['search'] = ltrim( $args['search'], '*' ); + } else if ( '' !== $args['search'] ) { + $args['search'] = trim( $args['search'], '*' ); + $args['search'] = '*' . $args['search'] . '*'; + } - if ( $role == 'super' ) { + if ( $role === 'super' ) { $logins = implode( "', '", get_super_admins() ); $args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" ); } - // If the network is large and a search is not being performed, show only the latest users with no paging in order - // to avoid expensive count queries. - if ( !$usersearch && ( get_blog_count() >= 10000 ) ) { + /* + * If the network is large and a search is not being performed, + * show only the latest users with no paging in order to avoid + * expensive count queries. + */ + if ( !$usersearch && wp_is_large_network( 'users' ) ) { if ( !isset($_REQUEST['orderby']) ) $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; if ( !isset($_REQUEST['order']) ) @@ -55,7 +81,15 @@ class WP_MS_Users_List_Table extends WP_List_Table { if ( isset( $_REQUEST['order'] ) ) $args['order'] = $_REQUEST['order']; - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + if ( ! empty( $_REQUEST['mode'] ) ) { + $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; + set_user_setting( 'network_users_list_mode', $mode ); + } else { + $mode = get_user_setting( 'network_users_list_mode', 'list' ); + } + + /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ + $args = apply_filters( 'users_list_table_query_args', $args ); // Query the user IDs for this page $wp_user_search = new WP_User_Query( $args ); @@ -68,7 +102,11 @@ class WP_MS_Users_List_Table extends WP_List_Table { ) ); } - function get_bulk_actions() { + /** + * + * @return array + */ + protected function get_bulk_actions() { $actions = array(); if ( current_user_can( 'delete_users' ) ) $actions['delete'] = __( 'Delete' ); @@ -78,51 +116,77 @@ class WP_MS_Users_List_Table extends WP_List_Table { return $actions; } - function no_items() { + /** + * @access public + */ + public function no_items() { _e( 'No users found.' ); } - function get_views() { - global $wp_roles, $role; + /** + * + * @global string $role + * @return array + */ + protected function get_views() { + global $role; $total_users = get_user_count(); $super_admins = get_super_admins(); $total_admins = count( $super_admins ); - $current_role = false; $class = $role != 'super' ? ' class="current"' : ''; $role_links = array(); $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; - $class = $role == 'super' ? ' class="current"' : ''; + $class = $role === 'super' ? ' class="current"' : ''; $role_links['super'] = "" . sprintf( _n( 'Super Admin (%s)', 'Super Admins (%s)', $total_admins ), number_format_i18n( $total_admins ) ) . ''; return $role_links; } - function pagination( $which ) { + /** + * @global string $mode + * @param string $which + */ + protected function pagination( $which ) { global $mode; parent::pagination ( $which ); - if ( 'top' == $which ) + if ( 'top' === $which ) { $this->view_switcher( $mode ); + } } - function get_columns() { + /** + * + * @return array + */ + public function get_columns() { $users_columns = array( 'cb' => '', 'username' => __( 'Username' ), 'name' => __( 'Name' ), - 'email' => __( 'E-mail' ), + 'email' => __( 'Email' ), 'registered' => _x( 'Registered', 'user' ), 'blogs' => __( 'Sites' ) ); - $users_columns = apply_filters( 'wpmu_users_columns', $users_columns ); - - return $users_columns; + /** + * Filters the columns displayed in the Network Admin Users list table. + * + * @since MU + * + * @param array $users_columns An array of user columns. Default 'cb', 'username', + * 'name', 'email', 'registered', 'blogs'. + */ + return apply_filters( 'wpmu_users_columns', $users_columns ); } - function get_sortable_columns() { + /** + * + * @return array + */ + protected function get_sortable_columns() { return array( 'username' => 'login', 'name' => 'name', @@ -131,146 +195,266 @@ class WP_MS_Users_List_Table extends WP_List_Table { ); } - function display_rows() { - global $current_site, $mode; + /** + * Handles the checkbox column output. + * + * @since 4.3.0 + * @access public + * + * @param WP_User $user The current WP_User object. + */ + public function column_cb( $user ) { + if ( is_super_admin( $user->ID ) ) { + return; + } + ?> + + + ID; + } - $alt = ''; + /** + * Handles the username column output. + * + * @since 4.3.0 + * @access public + * + * @param WP_User $user The current WP_User object. + */ + public function column_username( $user ) { $super_admins = get_super_admins(); + $avatar = get_avatar( $user->user_email, 32 ); + $edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) ); + + echo $avatar; + + ?>user_login; ?>user_login, $super_admins ) ) { + echo ' - ' . __( 'Super Admin' ); + } + ?> + first_name $user->last_name"; + } + + /** + * Handles the email column output. + * + * @since 4.3.0 + * @access public + * + * @param WP_User $user The current WP_User object. + */ + public function column_email( $user ) { + echo "$user->user_email"; + } + + /** + * Handles the registered date column output. + * + * @since 4.3.0 + * @access public + * + * @global string $mode + * + * @param WP_User $user The current WP_User object. + */ + public function column_registered( $user ) { + global $mode; + if ( 'list' === $mode ) { + $date = __( 'Y/m/d' ); + } else { + $date = __( 'Y/m/d g:i:s a' ); + } + echo mysql2date( $date, $user->user_registered ); + } + + /** + * @since 4.3.0 + * @access protected + * + * @param WP_User $user + * @param string $classes + * @param string $data + * @param string $primary + */ + protected function _column_blogs( $user, $classes, $data, $primary ) { + echo '