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

See #27743.


git-svn-id: https://develop.svn.wordpress.org/trunk@34636 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-09-27 19:10:08 +00:00
parent b3f49e0cdf
commit 8fa5426485
2 changed files with 18 additions and 9 deletions

View File

@ -214,13 +214,12 @@ class WP_Users_List_Table extends WP_List_Table {
* or below the table ("bottom").
*/
protected function extra_tablenav( $which ) {
if ( 'top' != $which )
return;
$id = 'bottom' === $which ? 'new_role2' : 'new_role';
?>
<div class="alignleft actions">
<?php if ( current_user_can( 'promote_users' ) ) : ?>
<label class="screen-reader-text" for="new_role"><?php _e( 'Change role to&hellip;' ) ?></label>
<select name="new_role" id="new_role">
<label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to&hellip;' ) ?></label>
<select name="<?php echo $id ?>" id="<?php echo $id ?>">
<option value=""><?php _e( 'Change role to&hellip;' ) ?></option>
<?php wp_dropdown_roles(); ?>
</select>
@ -250,8 +249,10 @@ class WP_Users_List_Table extends WP_List_Table {
* @return string The bulk action required.
*/
public function current_action() {
if ( isset($_REQUEST['changeit']) && !empty($_REQUEST['new_role']) )
if ( isset( $_REQUEST['changeit'] ) &&
( ! empty( $_REQUEST['new_role'] ) || ! empty( $_REQUEST['new_role2'] ) ) ) {
return 'promote';
}
return parent::current_action();
}

View File

@ -95,8 +95,16 @@ case 'promote':
}
$editable_roles = get_editable_roles();
if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
wp_die(__('You can&#8217;t give users that role.'));
$role = false;
if ( ! empty( $_REQUEST['new_role2'] ) ) {
$role = $_REQUEST['new_role2'];
} elseif ( ! empty( $_REQUEST['new_role'] ) ) {
$role = $_REQUEST['new_role'];
}
if ( ! $role || empty( $editable_roles[ $role ] ) ) {
wp_die( __( 'You can&#8217;t give users that role.' ) );
}
$userids = $_REQUEST['users'];
$update = 'promote';
@ -106,7 +114,7 @@ case 'promote':
if ( ! current_user_can('promote_user', $id) )
wp_die(__('You can&#8217;t edit that user.'));
// The new role of the current user must also have the promote_users cap or be a multisite super admin
if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users')
if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users')
&& ! ( is_multisite() && is_super_admin() ) ) {
$update = 'err_admin_role';
continue;
@ -122,7 +130,7 @@ case 'promote':
}
$user = get_userdata( $id );
$user->set_role($_REQUEST['new_role']);
$user->set_role( $role );
}
wp_redirect(add_query_arg('update', $update, $redirect));