diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/class-wp-ms-users-list-table.php --- a/wp/wp-admin/includes/class-wp-ms-users-list-table.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/class-wp-ms-users-list-table.php Tue Dec 15 13:49:49 2020 +0100 @@ -24,12 +24,19 @@ } /** + * @global string $mode List table view mode. * @global string $usersearch * @global string $role - * @global string $mode */ public function prepare_items() { - global $usersearch, $role, $mode; + global $mode, $usersearch, $role; + + if ( ! empty( $_REQUEST['mode'] ) ) { + $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; + set_user_setting( 'network_users_list_mode', $mode ); + } else { + $mode = get_user_setting( 'network_users_list_mode', 'list' ); + } $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : ''; @@ -54,7 +61,7 @@ $args['search'] = '*' . $args['search'] . '*'; } - if ( $role === 'super' ) { + if ( 'super' === $role ) { $args['login__in'] = get_super_admins(); } @@ -65,10 +72,12 @@ */ if ( ! $usersearch && wp_is_large_network( 'users' ) ) { if ( ! isset( $_REQUEST['orderby'] ) ) { - $_GET['orderby'] = $_REQUEST['orderby'] = 'id'; + $_GET['orderby'] = 'id'; + $_REQUEST['orderby'] = 'id'; } if ( ! isset( $_REQUEST['order'] ) ) { - $_GET['order'] = $_REQUEST['order'] = 'DESC'; + $_GET['order'] = 'DESC'; + $_REQUEST['order'] = 'DESC'; } $args['count_total'] = false; } @@ -81,17 +90,10 @@ $args['order'] = $_REQUEST['order']; } - 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 + // Query the user IDs for this page. $wp_user_search = new WP_User_Query( $args ); $this->items = $wp_user_search->get_results(); @@ -112,8 +114,8 @@ if ( current_user_can( 'delete_users' ) ) { $actions['delete'] = __( 'Delete' ); } - $actions['spam'] = _x( 'Mark as Spam', 'user' ); - $actions['notspam'] = _x( 'Not Spam', 'user' ); + $actions['spam'] = _x( 'Mark as spam', 'user' ); + $actions['notspam'] = _x( 'Not spam', 'user' ); return $actions; } @@ -135,11 +137,38 @@ $super_admins = get_super_admins(); $total_admins = count( $super_admins ); - $current_link_attributes = $role !== 'super' ? ' class="current" aria-current="page"' : ''; + $current_link_attributes = 'super' !== $role ? ' class="current" aria-current="page"' : ''; $role_links = array(); - $role_links['all'] = "" . sprintf( _nx( 'All (%s)', 'All (%s)', $total_users, 'users' ), number_format_i18n( $total_users ) ) . ''; - $current_link_attributes = $role === 'super' ? ' class="current" aria-current="page"' : ''; - $role_links['super'] = "" . sprintf( _n( 'Super Admin (%s)', 'Super Admins (%s)', $total_admins ), number_format_i18n( $total_admins ) ) . ''; + $role_links['all'] = sprintf( + '%s', + network_admin_url( 'users.php' ), + $current_link_attributes, + sprintf( + /* translators: Number of users. */ + _nx( + 'All (%s)', + 'All (%s)', + $total_users, + 'users' + ), + number_format_i18n( $total_users ) + ) + ); + $current_link_attributes = 'super' === $role ? ' class="current" aria-current="page"' : ''; + $role_links['super'] = sprintf( + '%s', + network_admin_url( 'users.php?role=super' ), + $current_link_attributes, + sprintf( + /* translators: Number of users. */ + _n( + 'Super Admin (%s)', + 'Super Admins (%s)', + $total_admins + ), + number_format_i18n( $total_admins ) + ) + ); return $role_links; } @@ -206,7 +235,12 @@ return; } ?> - + user_login, $super_admins ) ) { + if ( in_array( $user->user_login, $super_admins, true ) ) { echo ' — ' . __( 'Super Admin' ); } ?> @@ -337,17 +371,17 @@ continue; } - $path = ( $val->path === '/' ) ? '' : $val->path; + $path = ( '/' === $val->path ) ? '' : $val->path; $site_classes = array( 'site-' . $val->site_id ); /** * Filters the span class for a site listing on the mulisite user list table. * * @since 5.2.0 * - * @param array $site_classes Class used within the span tag. Default "site-#" with the site's network ID. - * @param int $site_id Site ID. - * @param int $network_id Network ID. - * @param object $user WP_User object. + * @param string[] $site_classes Array of class names used within the span tag. Default "site-#" with the site's network ID. + * @param int $site_id Site ID. + * @param int $network_id Network ID. + * @param WP_User $user WP_User object. */ $site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $val->userblog_id, $val->site_id, $user ); if ( is_array( $site_classes ) && ! empty( $site_classes ) ) { @@ -362,16 +396,16 @@ $actions['edit'] = '' . __( 'Edit' ) . ''; $class = ''; - if ( $val->spam == 1 ) { + if ( 1 == $val->spam ) { $class .= 'site-spammed '; } - if ( $val->mature == 1 ) { + if ( 1 == $val->mature ) { $class .= 'site-mature '; } - if ( $val->deleted == 1 ) { + if ( 1 == $val->deleted ) { $class .= 'site-deleted '; } - if ( $val->archived == 1 ) { + if ( 1 == $val->archived ) { $class .= 'site-archived '; } @@ -388,13 +422,18 @@ */ $actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id ); - $i = 0; $action_count = count( $actions ); + + $i = 0; + foreach ( $actions as $action => $link ) { ++$i; - $sep = ( $i == $action_count ) ? '' : ' | '; + + $sep = ( $i < $action_count ) ? ' | ' : ''; + echo "$link$sep"; } + echo '
'; } } @@ -404,8 +443,8 @@ * * @since 4.3.0 * - * @param WP_User $user The current WP_User object. - * @param string $column_name The current column name. + * @param WP_User $user The current WP_User object. + * @param string $column_name The current column name. */ public function column_default( $user, $column_name ) { /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ @@ -454,7 +493,8 @@ * @param object $user User being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. - * @return string Row actions output for users in Multisite. + * @return string Row actions output for users in Multisite, or an empty string + * if the current column is not the primary column. */ protected function handle_row_actions( $user, $column_name, $primary ) { if ( $primary !== $column_name ) { @@ -470,8 +510,8 @@ $actions['edit'] = '' . __( 'Edit' ) . ''; } - if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) { - $actions['delete'] = '' . __( 'Delete' ) . ''; + if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins, true ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; } /** @@ -483,6 +523,7 @@ * @param WP_User $user WP_User object. */ $actions = apply_filters( 'ms_user_row_actions', $actions, $user ); + return $this->row_actions( $actions ); } }