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

See #27743.

Built from https://develop.svn.wordpress.org/trunk@34636


git-svn-id: http://core.svn.wordpress.org/trunk@34600 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2015-09-27 19:11:26 +00:00
parent 9c46736476
commit f78170934a
3 changed files with 19 additions and 10 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));

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-34635';
$wp_version = '4.4-alpha-34636';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.