Make WordPress Core

Changeset 34963

Timestamp:
10/08/2015 09:58:34 PM (9 years ago)
Author:
johnbillion
Message:

On the Users list table, show all the roles of a user in a comma-separated list if they have more than one role. This prevents role obfuscation in situations where a user has had more than one role programmatically assigned to them.

Fixes #22959
Props scribu, JustinSainton, DrewAPicture, johnbillion

File:
1 edited

Legend:

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

    r34813 r34963  
    325325            $post_counts = count_many_users_posts( array_keys( $this->items ) );
    326326
    327         $editable_roles = array_keys( get_editable_roles() );
    328 
    329327        foreach ( $this->items as $userid => $user_object ) {
    330             if ( count( $user_object->roles ) <= 1 ) {
    331                 $role = reset( $user_object->roles );
    332             } elseif ( $roles = array_intersect( array_values( $user_object->roles ), $editable_roles ) ) {
    333                 $role = reset( $roles );
    334             } else {
    335                 $role = reset( $user_object->roles );
    336             }
    337 
    338328            if ( is_multisite() && empty( $user_object->allcaps ) )
    339329                continue;
    340330
    341             echo "\n\t" . $this->single_row( $user_object, $style = '', $role, isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
     331            echo "\n\t" . $this->single_row( $user_object, , isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
    342332        }
    343333    }
     
    347337     *
    348338     * @since 3.1.0
    349      * @since 4.2.0 The `$style` argument was deprecated.
     339     * @since 4.2.0 The `$style` parameter was deprecated.
     340     * @since 4.4.0 The `$role` parameter was deprecated.
    350341     * @access public
    351342     *
    352343     * @param object $user_object The current user object.
    353344     * @param string $style       Deprecated. Not used.
    354      * @param string $role        Optional. Key for the $wp_roles array. Default empty.
     345     * @param string $role        .
    355346     * @param int    $numposts    Optional. Post count to display for this user. Defaults
    356347     *                            to zero, as in, a new user has made zero posts.
     
    370361        else
    371362            $url = 'users.php?';
     363
     364
    372365
    373366        // Set up the hover actions for this user
     
    403396            $actions = apply_filters( 'user_row_actions', $actions, $user_object );
    404397
     398
     399
     400
    405401            // Set up the checkbox ( because the user is editable, otherwise it's empty )
    406402            $checkbox = '<label class="screen-reader-text" for="user_' . $user_object->ID . '">' . sprintf( __( 'Select %s' ), $user_object->user_login ) . '</label>'
    407                         . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='$role' value='{$user_object->ID}' />";
     403                        . "<input type='checkbox' name='users[]' id='user_{$user_object->ID}' class='' value='{$user_object->ID}' />";
    408404
    409405        } else {
     
    412408        $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
    413409        $avatar = get_avatar( $user_object->ID, 32 );
     410
     411
     412
    414413
    415414        $r = "<tr id='user-$user_object->ID'>";
     
    449448                        break;
    450449                    case 'role':
    451                         $r .= $role_name;
     450                        $r .= ;
    452451                        break;
    453452                    case 'posts':
     
    496495        return 'username';
    497496    }
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
     532
    498533}
Note: See TracChangeset for help on using the changeset viewer.