wp/wp-admin/includes/class-wp-ms-users-list-table.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
 * Multisite Users List Table class.
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 List_Table
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
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
class WP_MS_Users_List_Table extends WP_List_Table {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    12
	public function ajax_user_can() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
		return current_user_can( 'manage_network_users' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
	public function prepare_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
		global $usersearch, $role, $wpdb, $mode;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
		$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		$paged = $this->get_pagenum();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
		$args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
			'number' => $users_per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
			'offset' => ( $paged-1 ) * $users_per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
			'search' => $usersearch,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			'blog_id' => 0,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			'fields' => 'all_with_meta'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		if ( wp_is_large_network( 'users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			$args['search'] = ltrim( $args['search'], '*' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
		if ( $role == 'super' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
			$logins = implode( "', '", get_super_admins() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
			$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
		/*
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
		 * If the network is large and a search is not being performed,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
		 * show only the latest users with no paging in order to avoid
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    46
		 * expensive count queries.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
		if ( !$usersearch && wp_is_large_network( 'users' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
			if ( !isset($_REQUEST['orderby']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
				$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
			if ( !isset($_REQUEST['order']) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
				$_GET['order'] = $_REQUEST['order'] = 'DESC';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
			$args['count_total'] = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
		if ( isset( $_REQUEST['orderby'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
			$args['orderby'] = $_REQUEST['orderby'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
		if ( isset( $_REQUEST['order'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
			$args['order'] = $_REQUEST['order'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		// Query the user IDs for this page
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
		$wp_user_search = new WP_User_Query( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
		$this->items = $wp_user_search->get_results();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
		$this->set_pagination_args( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
			'total_items' => $wp_user_search->get_total(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
			'per_page' => $users_per_page,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    75
	protected function get_bulk_actions() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
		$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
		if ( current_user_can( 'delete_users' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
			$actions['delete'] = __( 'Delete' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
		$actions['spam'] = _x( 'Mark as Spam', 'user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
		$actions['notspam'] = _x( 'Not Spam', 'user' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    85
	public function no_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		_e( 'No users found.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    89
	protected function get_views() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    90
		global $role;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
		$total_users = get_user_count();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		$super_admins = get_super_admins();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
		$total_admins = count( $super_admins );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
		$class = $role != 'super' ? ' class="current"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
		$role_links = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
		$role_links['all'] = "<a href='" . network_admin_url('users.php') . "'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		$class = $role == 'super' ? ' class="current"' : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
		$role_links['super'] = "<a href='" . network_admin_url('users.php?role=super') . "'$class>" . sprintf( _n( 'Super Admin <span class="count">(%s)</span>', 'Super Admins <span class="count">(%s)</span>', $total_admins ), number_format_i18n( $total_admins ) ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		return $role_links;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   105
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   106
	 * @global string $mode
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   107
	 * @param string $which
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
	protected function pagination( $which ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
		global $mode;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
		parent::pagination ( $which );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
		if ( 'top' == $which )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
			$this->view_switcher( $mode );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   118
	public function get_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
		$users_columns = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
			'cb'         => '<input type="checkbox" />',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
			'username'   => __( 'Username' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   122
			'name'       => __( 'Name' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
			'email'      => __( 'E-mail' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
			'registered' => _x( 'Registered', 'user' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
			'blogs'      => __( 'Sites' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
		);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   127
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   128
		 * Filter the columns displayed in the Network Admin Users list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   129
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
		 * @since MU
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
		 * @param array $users_columns An array of user columns. Default 'cb', 'username',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
		 *                             'name', 'email', 'registered', 'blogs'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
		$users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
		return $users_columns;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   140
	protected function get_sortable_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
			'username'   => 'login',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
			'name'       => 'name',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
			'email'      => 'email',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
			'registered' => 'id',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
	public function display_rows() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
		global $mode;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
		$super_admins = get_super_admins();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
		foreach ( $this->items as $user ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
			$class = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
			$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
			foreach ( $status_list as $status => $col ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   159
				if ( $user->$status )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
					$class .= " $col";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
			?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   164
			<tr class="<?php echo trim( $class ); ?>">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
			list( $columns, $hidden ) = $this->get_column_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
			foreach ( $columns as $column_name => $column_display_name ) :
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
				$class = "class='$column_name column-$column_name'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
				$style = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
				if ( in_array( $column_name, $hidden ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
					$style = ' style="display:none;"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
				$attributes = "$class$style";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
				switch ( $column_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
					case 'cb': ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
						<th scope="row" class="check-column">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
							<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
							<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
						</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
					case 'username':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
						$avatar	= get_avatar( $user->user_email, 32 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
						$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
						echo "<td $attributes>"; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
							<?php echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
							if ( in_array( $user->user_login, $super_admins ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
								echo ' - ' . __( 'Super Admin' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
							?></strong>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
							<br/>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
							<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
								$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
								$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
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 ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
									$actions['delete'] = '<a href="' . $delete = esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
								}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
								/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
								 * Filter the action links displayed under each user
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   207
								 * in the Network Admin Users list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
								 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
								 * @since 3.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
								 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
								 * @param array   $actions An array of action links to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
								 *                         Default 'Edit', 'Delete'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
								 * @param WP_User $user    WP_User object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   214
								 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
								$actions = apply_filters( 'ms_user_row_actions', $actions, $user );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
								echo $this->row_actions( $actions );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
							?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
					<?php
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
					case 'name':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
						echo "<td $attributes>$user->first_name $user->last_name</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
					case 'email':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
						echo "<td $attributes><a href='mailto:$user->user_email'>$user->user_email</a></td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
					case 'registered':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
						if ( 'list' == $mode )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   232
							$date = __( 'Y/m/d' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
						else
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
							$date = __( 'Y/m/d g:i:s a' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
						echo "<td $attributes>" . mysql2date( $date, $user->user_registered ) . "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
					case 'blogs':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
						$blogs = get_blogs_of_user( $user->ID, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
						echo "<td $attributes>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
							if ( is_array( $blogs ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
								foreach ( (array) $blogs as $key => $val ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
									if ( !can_edit_network( $val->site_id ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
										continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
									$path	= ( $val->path == '/' ) ? '' : $val->path;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
									echo '<span class="site-' . $val->site_id . '" >';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
									echo '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . get_current_site()->domain, '', $val->domain . $path ) . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
									echo ' <small class="row-actions">';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
									$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
									$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
									$class = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
									if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
										$class .= 'site-spammed ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
									if ( get_blog_status( $val->userblog_id, 'mature' ) == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
										$class .= 'site-mature ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
									if ( get_blog_status( $val->userblog_id, 'deleted' ) == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
										$class .= 'site-deleted ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
									if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
										$class .= 'site-archived ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
									$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   266
									/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   267
									 * Filter the action links displayed next the sites a user belongs to
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   268
									 * in the Network Admin Users list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   269
									 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
									 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
									 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   272
									 * @param array $actions     An array of action links to be displayed.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   273
									 *                           Default 'Edit', 'View'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   274
									 * @param int   $userblog_id The site ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   275
									 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   276
									$actions = apply_filters( 'ms_user_list_site_actions', $actions, $val->userblog_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
									$i=0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
									$action_count = count( $actions );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
									foreach ( $actions as $action => $link ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
										++$i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
										( $i == $action_count ) ? $sep = '' : $sep = ' | ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
										echo "<span class='$action'>$link$sep</span>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
									}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
									echo '</small></span><br/>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
								}
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
						</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
					<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
					default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
						echo "<td $attributes>";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   295
						/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
						echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
						echo "</td>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
					break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
			endforeach
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
			?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
			</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
			<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
}