wp/wp-admin/network/site-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
 * Edit Site Users Administration Screen
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 Multisite
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/** Load WordPress Administration Bootstrap */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
require_once( dirname( __FILE__ ) . '/admin.php' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
if ( ! is_multisite() )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	wp_die( __( 'Multisite support is not enabled.' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
if ( ! current_user_can('manage_sites') )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	wp_die(__('You do not have sufficient permissions to edit this site.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
$wp_list_table = _get_list_table('WP_Users_List_Table');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
$wp_list_table->prepare_items();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
get_current_screen()->add_help_tab( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
	'id'      => 'overview',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	'title'   => __('Overview'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
	'content' =>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
		'<p>' . __('The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		'<p>' . __('<strong>Info</strong> - The domain and path are rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
		'<p>' . __('<strong>Users</strong> - This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.') . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
		'<p>' . sprintf( __('<strong>Themes</strong> - This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
		'<p>' . __('<strong>Settings</strong> - This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.') . '</p>'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
get_current_screen()->set_help_sidebar(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	'<p><strong>' . __('For more information:') . '</strong></p>' .
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    35
	'<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	'<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
$_SERVER['REQUEST_URI'] = remove_query_arg( 'update', $_SERVER['REQUEST_URI'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
$referer = remove_query_arg( 'update', wp_get_referer() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
if ( ! empty( $_REQUEST['paged'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	$referer = add_query_arg( 'paged', (int) $_REQUEST['paged'], $referer );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
$id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
if ( ! $id )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
	wp_die( __('Invalid site ID.') );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
$details = get_blog_details( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
if ( ! can_edit_network( $details->site_id ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    53
	wp_die( __( 'You do not have permission to access this page.' ), 403 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
$is_main_site = is_main_site( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
switch_to_blog( $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
$action = $wp_list_table->current_action();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
if ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
	switch ( $action ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		case 'newuser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
			check_admin_referer( 'add-user', '_wpnonce_add-new-user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
			$user = $_POST['user'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
			if ( ! is_array( $_POST['user'] ) || empty( $user['username'] ) || empty( $user['email'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
				$update = 'err_new';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				$password = wp_generate_password( 12, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
				$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
				if ( false == $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		 			$update = 'err_new_dup';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
					wp_new_user_notification( $user_id, $password );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
					add_user_to_blog( $id, $user_id, $_POST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
					$update = 'newuser';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		case 'adduser':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			check_admin_referer( 'add-user', '_wpnonce_add-user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
			if ( !empty( $_POST['newuser'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
				$update = 'adduser';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
				$newuser = $_POST['newuser'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
				$user = get_user_by( 'login', $newuser );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
				if ( $user && $user->exists() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
					if ( ! is_user_member_of_blog( $user->ID, $id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
						add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
					else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
						$update = 'err_add_member';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
					$update = 'err_add_notfound';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
				$update = 'err_add_notfound';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		case 'remove':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
			if ( ! current_user_can( 'remove_users' )  )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
				die(__('You can&#8217;t remove users.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
			check_admin_referer( 'bulk-users' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
			$update = 'remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
			if ( isset( $_REQUEST['users'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
				$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
				foreach ( $userids as $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
					$user_id = (int) $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
					remove_user_from_blog( $user_id, $id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			} elseif ( isset( $_GET['user'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
				remove_user_from_blog( $_GET['user'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
				$update = 'err_remove';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
		case 'promote':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			check_admin_referer( 'bulk-users' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			$editable_roles = get_editable_roles();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			if ( empty( $editable_roles[$_REQUEST['new_role']] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
				wp_die(__('You can&#8217;t give users that role.'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
			if ( isset( $_REQUEST['users'] ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
				$userids = $_REQUEST['users'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
				$update = 'promote';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
				foreach ( $userids as $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
					$user_id = (int) $user_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
					// If the user doesn't already belong to the blog, bail.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
					if ( !is_user_member_of_blog( $user_id ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
						wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
					$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
					$user->set_role( $_REQUEST['new_role'] );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
				$update = 'err_promote';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
	wp_safe_redirect( add_query_arg( 'update', $update, $referer ) );
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
restore_current_blog();
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 ( isset( $_GET['action'] ) && 'update-site' == $_GET['action'] ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
	wp_safe_redirect( $referer );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
	exit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
add_screen_option( 'per_page' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
$site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
$title_site_url_linked = sprintf( __( 'Edit Site: %s' ), '<a href="' . get_blogaddress_by_id( $id ) . '">' . $site_url_no_http . '</a>' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   162
$title = sprintf( __( 'Edit Site: %s' ), $site_url_no_http );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
$parent_file = 'sites.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
$submenu_file = 'sites.php';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   167
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   168
 * Filter whether to show the Add Existing User form on the Multisite Users screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   171
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
 * @param bool $bool Whether to show the Add Existing User form. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
	wp_enqueue_script( 'user-suggest' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
require( ABSPATH . 'wp-admin/admin-header.php' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
<script type="text/javascript">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
var current_site_id = <?php echo $id; ?>;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
</script>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
<div class="wrap">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
<h2 id="edit-site"><?php echo $title_site_url_linked ?></h2>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
<h3 class="nav-tab-wrapper">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
$tabs = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
	'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
	'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
	'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
foreach ( $tabs as $tab_id => $tab ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
	$class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
</h3><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
if ( isset($_GET['update']) ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
	switch($_GET['update']) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
	case 'adduser':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
		echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User added.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
	case 'err_add_member':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'User is already a member of this site.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
	case 'err_add_notfound':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Enter the username of an existing user.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
	case 'promote':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
		echo '<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
   214
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
	case 'err_promote':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   216
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Select a user to change role.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
	case 'remove':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
		echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User removed from this site.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
	case 'err_remove':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Select a user to remove.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
	case 'newuser':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   225
		echo '<div id="message" class="updated notice is-dismissible"><p>' . __( 'User created.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	case 'err_new':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   228
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Enter the username and email.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
	case 'err_new_dup':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
		echo '<div id="message" class="error notice is-dismissible"><p>' . __( 'Duplicated username or email address.' ) . '</p></div>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   236
<form class="search-form" method="get">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
<?php $wp_list_table->views(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
<form method="post" action="site-users.php?action=update-site">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
<?php $wp_list_table->display(); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
 * Fires after the list table on the Users screen in the Multisite Network Admin.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   253
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
do_action( 'network_site_users_after_list_table' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   258
/** This filter is documented in wp-admin/network/site-users.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   259
if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) ) : ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
<h3 id="add-existing-user"><?php _e( 'Add Existing User' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
<form action="site-users.php?action=adduser" id="adduser" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
	<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
		<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   265
			<th scope="row"><label for="newuser"><?php _e( 'Username' ); ?></label></th>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			<td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
		<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   269
			<th scope="row"><label for="new_role_adduser"><?php _e( 'Role' ); ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
			<td><select name="new_role" id="new_role_adduser">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
			<?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
			</select></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
	</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
	<?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
	<?php submit_button( __( 'Add User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-existing-user' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   280
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   281
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   282
 * Filter whether to show the Add New User form on the Multisite Users screen.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   283
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   284
 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   285
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
 * @param bool $bool Whether to show the Add New User form. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   287
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   288
if ( current_user_can( 'create_users' ) && apply_filters( 'show_network_site_users_add_new_form', true ) ) : ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
<h3 id="add-new-user"><?php _e( 'Add New User' ); ?></h3>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
<form action="<?php echo network_admin_url('site-users.php?action=newuser'); ?>" id="newuser" method="post">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
	<input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
	<table class="form-table">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
		<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   294
			<th scope="row"><label for="user_username"><?php _e( 'Username' ) ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
			<td><input type="text" class="regular-text" name="user[username]" id="user_username" /></td>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
		<tr>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   298
			<th scope="row"><label for="user_email"><?php _e( 'Email' ) ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
			<td><input type="text" class="regular-text" name="user[email]" id="user_email" /></td>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
		</tr>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
		<tr>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
			<th scope="row"><label for="new_role_newuser"><?php _e( 'Role' ); ?></label></th>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
			<td><select name="new_role" id="new_role_newuser">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
			<?php wp_dropdown_roles( get_option( 'default_role' ) ); ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
			</select></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
		<tr class="form-field">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
			<td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
		</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	</table>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
	<?php wp_nonce_field( 'add-user', '_wpnonce_add-new-user' ) ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	<?php submit_button( __( 'Add New User' ), 'primary', 'add-user', true, array( 'id' => 'submit-add-user' ) ); ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
</form>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
<?php endif; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
require( ABSPATH . 'wp-admin/admin-footer.php' );