WordPress.org

Make WordPress Core

Changeset 34636


Ignore:
Timestamp:
09/27/2015 07:10:08 PM (4 years ago)
Author:
wonderboymusic
Message:

Users List Table: show the "Change role to" dropdown on the top and bottom. Currently only shows on top.

See #27743.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

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

    r34383 r34636  
    215215     */
    216216    protected function extra_tablenav( $which ) {
    217         if ( 'top' != $which )
    218             return;
     217        $id = 'bottom' === $which ? 'new_role2' : 'new_role';
    219218    ?>
    220219    <div class="alignleft actions">
    221220        <?php if ( current_user_can( 'promote_users' ) ) : ?>
    222         <label class="screen-reader-text" for="new_role"><?php _e( 'Change role to&hellip;' ) ?></label>
    223         <select name="new_role" id="new_role">
     221        <label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to&hellip;' ) ?></label>
     222        <select name="<?php echo $id ?>" id="<?php echo $id ?>">
    224223            <option value=""><?php _e( 'Change role to&hellip;' ) ?></option>
    225224            <?php wp_dropdown_roles(); ?>
     
    251250     */
    252251    public function current_action() {
    253         if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
     252        if ( isset( $_REQUEST['changeit'] ) &&
     253            ( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) {
    254254            return 'promote';
     255        }
    255256
    256257        return parent::current_action();
  • trunk/src/wp-admin/users.php

    r34393 r34636  
    9696
    9797    $editable_roles = get_editable_roles();
    98     if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
    99         wp_die(__('You can&#8217;t give users that role.'));
     98    $role = false;
     99    if ( ! empty( $_REQUEST['new_role2'] ) ) {
     100        $role = $_REQUEST['new_role2'];
     101    } elseif ( ! empty( $_REQUEST['new_role'] ) ) {
     102        $role = $_REQUEST['new_role'];
     103    }
     104
     105    if ( ! $role || empty( $editable_roles[ $role ] ) ) {
     106        wp_die( __( 'You can&#8217;t give users that role.' ) );
     107    }
    100108
    101109    $userids = $_REQUEST['users'];
     
    107115            wp_die(__('You can&#8217;t edit that user.'));
    108116        // The new role of the current user must also have the promote_users cap or be a multisite super admin
    109         if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users')
     117        if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users')
    110118            && ! ( is_multisite() && is_super_admin() ) ) {
    111119                $update = 'err_admin_role';
     
    123131
    124132        $user = get_userdata( $id );
    125         $user->set_role($_REQUEST['new_role']);
     133        $user->set_role( $role );
    126134    }
    127135
Note: See TracChangeset for help on using the changeset viewer.