Ticket #22959: 22959.4.diff
File 22959.4.diff, 3.6 KB (added by , 11 years ago) |
---|
-
src/wp-admin/includes/class-wp-users-list-table.php
193 193 if ( ! $this->is_site_users ) 194 194 $post_counts = count_many_users_posts( array_keys( $this->items ) ); 195 195 196 $editable_roles = array_keys( get_editable_roles() );197 198 196 $style = ''; 199 197 foreach ( $this->items as $userid => $user_object ) { 200 if ( count( $user_object->roles ) <= 1 ) {201 $role = reset( $user_object->roles );202 } elseif ( $roles = array_intersect( array_values( $user_object->roles ), $editable_roles ) ) {203 $role = reset( $roles );204 } else {205 $role = reset( $user_object->roles );206 }207 198 208 199 if ( is_multisite() && empty( $user_object->allcaps ) ) 209 200 continue; … … 237 228 else 238 229 $url = 'users.php?'; 239 230 231 $user_roles = $this->get_role_list( $user_object ); 232 240 233 $checkbox = ''; 241 234 // Check if the user for this row is editable 242 235 if ( current_user_can( 'list_users' ) ) { … … 260 253 $actions = apply_filters( 'user_row_actions', $actions, $user_object ); 261 254 $edit .= $this->row_actions( $actions ); 262 255 256 // Role classes. 257 $role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) ); 258 263 259 // Set up the checkbox ( because the user is editable, otherwise it's empty ) 264 260 $checkbox = '<label class="screen-reader-text" for="cb-select-' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>' 265 . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role ' value='{$user_object->ID}' />";261 . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role_classes' value='{$user_object->ID}' />"; 266 262 267 263 } else { 268 264 $edit = '<strong>' . $user_object->user_login . '</strong>'; 269 265 } 270 $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' ); 266 271 267 $avatar = get_avatar( $user_object->ID, 32 ); 272 268 269 // Comma-separated list of user roles. 270 $roles_list = implode( ', ', $user_roles ); 271 273 272 $r = "<tr id='user-$user_object->ID'$style>"; 274 273 275 274 list( $columns, $hidden ) = $this->get_column_info(); … … 297 296 $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>"; 298 297 break; 299 298 case 'role': 300 $r .= "<td $attributes> $role_name</td>";299 $r .= "<td $attributes>" . esc_html( $roles_list ) . "</td>"; 301 300 break; 302 301 case 'posts': 303 302 $attributes = 'class="posts column-posts num"' . $style; … … 321 320 322 321 return $r; 323 322 } 323 324 /** 325 * Generate an array of user roles for a given user object. 326 * 327 * @access protected 328 * @since 3.7.0 329 * 330 * @param WP_User $user_object The WP_User object. 331 * @return array An array of user roles. 332 */ 333 protected function get_role_list( $user_object ) { 334 global $wp_roles; 335 336 $role_list = array(); 337 338 foreach ( $user_object->roles as $role ) { 339 if ( isset( $wp_roles->role_names[ $role ] ) ) 340 $role_list[$role] = translate_user_role( $wp_roles->role_names[ $role ] ); 341 } 342 343 if ( empty( $role_list ) ) 344 $role_list['none'] = _x( 'None', 'no user roles' ); 345 346 /** 347 * Filter the returned array of roles for a user. 348 * 349 * @since 3.7.0 350 * 351 * @param array $role_list An array of user roles. 352 * @param WP_User $user_object A WP_User object. 353 */ 354 return apply_filters( 'get_role_list', $role_list, $user_object ); 355 } 324 356 }