wp/wp-admin/users.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Users administration panel.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Administration
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/** WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
if ( ! current_user_can( 'list_users' ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
	wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
$wp_list_table = _get_list_table('WP_Users_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
$pagenum = $wp_list_table->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
$title = __('Users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
$parent_file = 'users.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
add_screen_option( 'per_page' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
// contextual help - choose Help on the top right of admin panel to preview this.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	'id'      => 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
	'content' => '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options in the dashboard navigation when they are logged in, based on their role.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
				 '<p>' . __('To add a new user for your site, click the Add New button at the top of the screen or Add New in the Users menu section.') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
) ) ;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
	'id'      => 'screen-display',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	'title'   => __('Screen Display'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	'content' => '<p>' . __('You can customize the display of this screen in a number of ways:') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
					'<ul>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
					'<li>' . __('You can hide/display columns based on your needs and decide how many users to list per screen using the Screen Options tab.') . '</li>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
					'<li>' . __('You can filter the list of users by User Role using the text links in the upper left to show All, Administrator, Editor, Author, Contributor, or Subscriber. The default view is to show all users. Unused User Roles are not listed.') . '</li>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
					'<li>' . __('You can view all posts made by a user by clicking on the number under the Posts column.') . '</li>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
					'</ul>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
$help = '<p>' . __('Hovering over a row in the users list will display action links that allow you to manage users. You can perform the following actions:') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	'<ul>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	'<li>' . __('Edit takes you to the editable profile screen for that user. You can also reach that screen by clicking on the username.') . '</li>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
if ( is_multisite() )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
	$help .= '<li>' . __( 'Remove allows you to remove a user from your site. It does not delete their content. You can also remove multiple users at once by using Bulk Actions.' ) . '</li>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
else
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    48
	$help .= '<li>' . __( 'Delete brings you to the Delete Users screen for confirmation, where you can permanently remove a user from your site and delete their content. You can also delete multiple users at once by using Bulk Actions.' ) . '</li>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
$help .= '</ul>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
	'id'      => 'actions',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
	'title'   => __('Actions'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
	'content' => $help,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
unset( $help );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
    '<p><strong>' . __('For more information:') . '</strong></p>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
    '<p>' . __('<a href="https://codex.wordpress.org/Users_Screen" target="_blank">Documentation on Managing Users</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
    '<p>' . __('<a href="https://codex.wordpress.org/Roles_and_Capabilities" target="_blank">Descriptions of Roles and Capabilities</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
    '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
if ( empty($_REQUEST) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	$referer = '<input type="hidden" name="wp_http_referer" value="'. esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
} elseif ( isset($_REQUEST['wp_http_referer']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
	$redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), wp_unslash( $_REQUEST['wp_http_referer'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
	$referer = '<input type="hidden" name="wp_http_referer" value="' . esc_attr($redirect) . '" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
	$redirect = 'users.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	$referer = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
$update = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
function delete_users_add_js() { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
<script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
jQuery(document).ready( function($) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
	var submit = $('#submit').prop('disabled', true);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
	$('input[name=delete_option]').one('change', function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
		submit.prop('disabled', false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	$('#reassign_user').focus( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
		$('#delete_option1').prop('checked', true).trigger('change');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
	});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
switch ( $wp_list_table->current_action() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
/* Bulk Dropdown menu Role changes */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
case 'promote':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
	check_admin_referer('bulk-users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
	if ( ! current_user_can( 'promote_users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
		wp_die( __( 'You can&#8217;t edit that user.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
	if ( empty($_REQUEST['users']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
		wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
	$editable_roles = get_editable_roles();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
	if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
		wp_die(__('You can&#8217;t give users that role.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
	$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
	$update = 'promote';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	foreach ( $userids as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
		$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
		if ( ! current_user_can('promote_user', $id) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
			wp_die(__('You can&#8217;t edit that user.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		// The new role of the current user must also have the promote_users cap or be a multisite super admin
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
		if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $_REQUEST['new_role'] ]->has_cap('promote_users')
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			&& ! ( is_multisite() && is_super_admin() ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
				$update = 'err_admin_role';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		// If the user doesn't already belong to the blog, bail.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
		if ( is_multisite() && !is_user_member_of_blog( $id ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
			wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
		$user = get_userdata( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		$user->set_role($_REQUEST['new_role']);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
	wp_redirect(add_query_arg('update', $update, $redirect));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
case 'dodelete':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
	if ( is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
		wp_die( __('User deletion is not allowed from this screen.') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
	check_admin_referer('delete-users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
	if ( empty($_REQUEST['users']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
		wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
	$userids = array_map( 'intval', (array) $_REQUEST['users'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
	if ( empty( $_REQUEST['delete_option'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
		$url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
		$url = str_replace( '&amp;', '&', wp_nonce_url( $url, 'bulk-users' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
		wp_redirect( $url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
	if ( ! current_user_can( 'delete_users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
		wp_die(__('You can&#8217;t delete users.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
	$update = 'del';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	$delete_count = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
	foreach ( $userids as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
		if ( ! current_user_can( 'delete_user', $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
			wp_die(__( 'You can&#8217;t delete that user.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
		if ( $id == $current_user->ID ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
			$update = 'err_admin_del';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		switch ( $_REQUEST['delete_option'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
		case 'delete':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
			wp_delete_user( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
		case 'reassign':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
			wp_delete_user( $id, $_REQUEST['reassign_user'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
		++$delete_count;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	$redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
	wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
case 'delete':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
	if ( is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
		wp_die( __('User deletion is not allowed from this screen.') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
	check_admin_referer('bulk-users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
		wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
	if ( ! current_user_can( 'delete_users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
		$errors = new WP_Error( 'edit_users', __( 'You can&#8217;t delete users.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
	if ( empty($_REQUEST['users']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
		$userids = array( intval( $_REQUEST['user'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
		$userids = array_map( 'intval', (array) $_REQUEST['users'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	add_action( 'admin_head', 'delete_users_add_js' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	include( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
<form method="post" name="updateusers" id="updateusers">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
<?php wp_nonce_field('delete-users') ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
<?php echo $referer; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
<h2><?php _e('Delete Users'); ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
<?php if ( isset( $_REQUEST['error'] ) ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
	<div class="error">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
		<p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   221
	</div>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
<?php endif; ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   223
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
<?php if ( 1 == count( $userids ) ) : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
	<p><?php _e( 'You have specified this user for deletion:' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   226
<?php else : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
	<p><?php _e( 'You have specified these users for deletion:' ); ?></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
<?php endif; ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
	$go_delete = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
	foreach ( $userids as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
		$user = get_userdata( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
		if ( $id == $current_user->ID ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
			echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
			echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
			$go_delete++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
	?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
	</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
<?php if ( $go_delete ) : ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   245
	<?php if ( 1 == $go_delete ) : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   246
		<fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   247
	<?php else : ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
		<fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
	<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
	<ul style="list-style:none;">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
		<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
		<?php _e('Delete all content.'); ?></label></li>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
		<li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
		<?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
		wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	</ul></fieldset>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   257
	<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   258
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
	 * Fires at the end of the delete users form prior to the confirm button.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   260
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   261
	 * @since 4.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   263
	 * @param WP_User $current_user WP_User object for the user being deleted.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   264
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   265
	do_action( 'delete_user_form', $current_user );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   266
	?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
	<input type="hidden" name="action" value="dodelete" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
	<?php submit_button( __('Confirm Deletion'), 'secondary' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
<?php else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
	<p><?php _e('There are no valid users selected for deletion.'); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
case 'doremove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
	check_admin_referer('remove-users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
	if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
		wp_die( __( 'You can&#8217;t remove users.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
	if ( empty($_REQUEST['users']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
		wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
	if ( ! current_user_can( 'remove_users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
		wp_die( __( 'You can&#8217;t remove users.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
	$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
	$update = 'remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
 	foreach ( $userids as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
		if ( $id == $current_user->ID && !is_super_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
			$update = 'err_admin_remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
		if ( !current_user_can('remove_user', $id) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
			$update = 'err_admin_remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
			continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
		remove_user_from_blog($id, $blog_id);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
	$redirect = add_query_arg( array('update' => $update), $redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
	wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
case 'remove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
	check_admin_referer('bulk-users');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
	if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
		wp_die( __( 'You can&#8217;t remove users.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
	if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
		wp_redirect($redirect);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
		exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
	if ( !current_user_can('remove_users') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
		$error = new WP_Error('edit_users', __('You can&#8217;t remove users.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
	if ( empty($_REQUEST['users']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
		$userids = array(intval($_REQUEST['user']));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
	else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
		$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
	include( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   334
<form method="post" name="updateusers" id="updateusers">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
<?php wp_nonce_field('remove-users') ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
<?php echo $referer; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
<h2><?php _e('Remove Users from Site'); ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
<p><?php _e('You have specified these users for removal:'); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	$go_remove = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
 	foreach ( $userids as $id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
		$id = (int) $id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
 		$user = get_userdata( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
		if ( $id == $current_user->ID && !is_super_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
			echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
		} elseif ( !current_user_can('remove_user', $id) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
			echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
			echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
			$go_remove = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
 	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 	?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
</ul>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
<?php if ( $go_remove ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		<input type="hidden" name="action" value="doremove" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
		<?php submit_button( __('Confirm Removal'), 'secondary' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
<?php else : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
	<p><?php _e('There are no valid users selected for removal.'); ?></p>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	if ( !empty($_GET['_wp_http_referer']) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
		wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
	$wp_list_table->prepare_items();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
	$total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
	if ( $pagenum > $total_pages && $total_pages > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
		wp_redirect( add_query_arg( 'paged', $total_pages ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
		exit;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
	include( ABSPATH . 'wp-admin/admin-header.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
	$messages = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
	if ( isset($_GET['update']) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
		switch($_GET['update']) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
		case 'del':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		case 'del_many':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
			$delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
			if ( 1 == $delete_count ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
				$message = __( 'User deleted.' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   394
			} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   395
				$message = _n( '%s user deleted.', '%s users deleted.', $delete_count );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   396
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
			$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
		case 'add':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
			if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
				$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
					esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
						self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
			} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
				$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
		case 'promote':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
			$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
		case 'err_admin_role':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
			$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user&#8217;s role must have user editing capabilities.') . '</p></div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
			$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
		case 'err_admin_del':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
			$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can&#8217;t delete the current user.') . '</p></div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
			$messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
		case 'remove':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
			$messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
		case 'err_admin_remove':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   423
			$messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
			$messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
	endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
<?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
	<div class="error">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
		<ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
			foreach ( $errors->get_error_messages() as $err )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
				echo "<li>$err</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
		?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
		</ul>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
	</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
<?php endif;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
if ( ! empty($messages) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
	foreach ( $messages as $msg )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
		echo $msg;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
} ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
<h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
echo esc_html( $title );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
if ( current_user_can( 'create_users' ) ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
	<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
<?php } elseif ( is_multisite() && current_user_can( 'promote_users' ) ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
	<a href="user-new.php" class="add-new-h2"><?php echo esc_html_x( 'Add Existing', 'user' ); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
<?php }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
if ( $usersearch )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
	printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $usersearch ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
</h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
<?php $wp_list_table->views(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   461
<form method="get">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
<?php $wp_list_table->display(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
<br class="clear" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
} // end of the $doaction switch
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
include( ABSPATH . 'wp-admin/admin-footer.php' );