Ticket #22959: 22959.1.diff
File 22959.1.diff, 2.9 KB (added by , 11 years ago) |
---|
-
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; 210 201 211 202 $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"'; 212 echo "\n\t" . $this->single_row( $user_object, $style, $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );203 echo "\n\t", $this->single_row( $user_object, $style, isset( $post_counts ) ? $post_counts[ $userid ] : 0 ); 213 204 } 214 205 } 215 206 … … 220 211 * 221 212 * @param object $user_object 222 213 * @param string $style Optional. Attributes added to the TR element. Must be sanitized. 223 * @param string $role Key for the $wp_roles array.224 214 * @param int $numposts Optional. Post count to display for this user. Defaults to zero, as in, a new user has made zero posts. 225 215 * @return string 226 216 */ 227 function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) { 228 global $wp_roles; 217 function single_row( $user_object, $style = '', $numposts = 0 ) { 229 218 230 219 if ( !( is_object( $user_object ) && is_a( $user_object, 'WP_User' ) ) ) 231 220 $user_object = get_userdata( (int) $user_object ); … … 267 256 } else { 268 257 $edit = '<strong>' . $user_object->user_login . '</strong>'; 269 258 } 270 $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' ); 259 271 260 $avatar = get_avatar( $user_object->ID, 32 ); 272 261 273 262 $r = "<tr id='user-$user_object->ID'$style>"; … … 297 286 $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>"; 298 287 break; 299 288 case 'role': 300 $r .= "<td $attributes> $role_name</td>";289 $r .= "<td $attributes>" . $this->get_role_str( $user_object ) . "</td>"; 301 290 break; 302 291 case 'posts': 303 292 $attributes = 'class="posts column-posts num"' . $style; … … 321 310 322 311 return $r; 323 312 } 313 private function get_role_str( $user_object ) { 314 global $wp_roles; 315 316 $role_str = array(); 317 318 foreach ( $user_object->roles as $role ) { 319 if ( isset( $wp_roles->role_names[$role] ) ) 320 $role_str[] = translate_user_role( $wp_roles->role_names[$role] ); 321 } 322 323 if ( empty( $role_str ) ) 324 return __( 'None' ); 325 326 return implode( ', ', $role_str ); 327 } 324 328 }