wp/wp-admin/includes/class-wp-users-list-table.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    41 	 * @see WP_List_Table::__construct() for more information on default arguments.
    41 	 * @see WP_List_Table::__construct() for more information on default arguments.
    42 	 *
    42 	 *
    43 	 * @param array $args An associative array of arguments.
    43 	 * @param array $args An associative array of arguments.
    44 	 */
    44 	 */
    45 	public function __construct( $args = array() ) {
    45 	public function __construct( $args = array() ) {
    46 		parent::__construct( array(
    46 		parent::__construct(
    47 			'singular' => 'user',
    47 			array(
    48 			'plural'   => 'users',
    48 				'singular' => 'user',
    49 			'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
    49 				'plural'   => 'users',
    50 		) );
    50 				'screen'   => isset( $args['screen'] ) ? $args['screen'] : null,
       
    51 			)
       
    52 		);
    51 
    53 
    52 		$this->is_site_users = 'site-users-network' === $this->screen->id;
    54 		$this->is_site_users = 'site-users-network' === $this->screen->id;
    53 
    55 
    54 		if ( $this->is_site_users )
    56 		if ( $this->is_site_users ) {
    55 			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
    57 			$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
       
    58 		}
    56 	}
    59 	}
    57 
    60 
    58 	/**
    61 	/**
    59 	 * Check the current user's permissions.
    62 	 * Check the current user's permissions.
    60 	 *
    63 	 *
    61  	 * @since 3.1.0
    64 	 * @since 3.1.0
    62 	 *
    65 	 *
    63 	 * @return bool
    66 	 * @return bool
    64 	 */
    67 	 */
    65 	public function ajax_user_can() {
    68 	public function ajax_user_can() {
    66 		if ( $this->is_site_users )
    69 		if ( $this->is_site_users ) {
    67 			return current_user_can( 'manage_sites' );
    70 			return current_user_can( 'manage_sites' );
    68 		else
    71 		} else {
    69 			return current_user_can( 'list_users' );
    72 			return current_user_can( 'list_users' );
       
    73 		}
    70 	}
    74 	}
    71 
    75 
    72 	/**
    76 	/**
    73 	 * Prepare the users list for display.
    77 	 * Prepare the users list for display.
    74 	 *
    78 	 *
    82 
    86 
    83 		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
    87 		$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
    84 
    88 
    85 		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
    89 		$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
    86 
    90 
    87 		$per_page = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
    91 		$per_page       = ( $this->is_site_users ) ? 'site_users_network_per_page' : 'users_per_page';
    88 		$users_per_page = $this->get_items_per_page( $per_page );
    92 		$users_per_page = $this->get_items_per_page( $per_page );
    89 
    93 
    90 		$paged = $this->get_pagenum();
    94 		$paged = $this->get_pagenum();
    91 
    95 
    92 		if ( 'none' === $role ) {
    96 		if ( 'none' === $role ) {
    93 			$args = array(
    97 			$args = array(
    94 				'number' => $users_per_page,
    98 				'number'  => $users_per_page,
    95 				'offset' => ( $paged-1 ) * $users_per_page,
    99 				'offset'  => ( $paged - 1 ) * $users_per_page,
    96 				'include' => wp_get_users_with_no_role( $this->site_id ),
   100 				'include' => wp_get_users_with_no_role( $this->site_id ),
    97 				'search' => $usersearch,
   101 				'search'  => $usersearch,
    98 				'fields' => 'all_with_meta'
   102 				'fields'  => 'all_with_meta',
    99 			);
   103 			);
   100 		} else {
   104 		} else {
   101 			$args = array(
   105 			$args = array(
   102 				'number' => $users_per_page,
   106 				'number' => $users_per_page,
   103 				'offset' => ( $paged-1 ) * $users_per_page,
   107 				'offset' => ( $paged - 1 ) * $users_per_page,
   104 				'role' => $role,
   108 				'role'   => $role,
   105 				'search' => $usersearch,
   109 				'search' => $usersearch,
   106 				'fields' => 'all_with_meta'
   110 				'fields' => 'all_with_meta',
   107 			);
   111 			);
   108 		}
   112 		}
   109 
   113 
   110 		if ( '' !== $args['search'] )
   114 		if ( '' !== $args['search'] ) {
   111 			$args['search'] = '*' . $args['search'] . '*';
   115 			$args['search'] = '*' . $args['search'] . '*';
   112 
   116 		}
   113 		if ( $this->is_site_users )
   117 
       
   118 		if ( $this->is_site_users ) {
   114 			$args['blog_id'] = $this->site_id;
   119 			$args['blog_id'] = $this->site_id;
   115 
   120 		}
   116 		if ( isset( $_REQUEST['orderby'] ) )
   121 
       
   122 		if ( isset( $_REQUEST['orderby'] ) ) {
   117 			$args['orderby'] = $_REQUEST['orderby'];
   123 			$args['orderby'] = $_REQUEST['orderby'];
   118 
   124 		}
   119 		if ( isset( $_REQUEST['order'] ) )
   125 
       
   126 		if ( isset( $_REQUEST['order'] ) ) {
   120 			$args['order'] = $_REQUEST['order'];
   127 			$args['order'] = $_REQUEST['order'];
       
   128 		}
   121 
   129 
   122 		/**
   130 		/**
   123 		 * Filters the query arguments used to retrieve users for the current users list table.
   131 		 * Filters the query arguments used to retrieve users for the current users list table.
   124 		 *
   132 		 *
   125 		 * @since 4.4.0
   133 		 * @since 4.4.0
   132 		// Query the user IDs for this page
   140 		// Query the user IDs for this page
   133 		$wp_user_search = new WP_User_Query( $args );
   141 		$wp_user_search = new WP_User_Query( $args );
   134 
   142 
   135 		$this->items = $wp_user_search->get_results();
   143 		$this->items = $wp_user_search->get_results();
   136 
   144 
   137 		$this->set_pagination_args( array(
   145 		$this->set_pagination_args(
   138 			'total_items' => $wp_user_search->get_total(),
   146 			array(
   139 			'per_page' => $users_per_page,
   147 				'total_items' => $wp_user_search->get_total(),
   140 		) );
   148 				'per_page'    => $users_per_page,
       
   149 			)
       
   150 		);
   141 	}
   151 	}
   142 
   152 
   143 	/**
   153 	/**
   144 	 * Output 'no users' message.
   154 	 * Output 'no users' message.
   145 	 *
   155 	 *
   171 			$url = 'site-users.php?id=' . $this->site_id;
   181 			$url = 'site-users.php?id=' . $this->site_id;
   172 			switch_to_blog( $this->site_id );
   182 			switch_to_blog( $this->site_id );
   173 			$users_of_blog = count_users( 'time', $this->site_id );
   183 			$users_of_blog = count_users( 'time', $this->site_id );
   174 			restore_current_blog();
   184 			restore_current_blog();
   175 		} else {
   185 		} else {
   176 			$url = 'users.php';
   186 			$url           = 'users.php';
   177 			$users_of_blog = count_users();
   187 			$users_of_blog = count_users();
   178 		}
   188 		}
   179 
   189 
   180 		$total_users = $users_of_blog['total_users'];
   190 		$total_users = $users_of_blog['total_users'];
   181 		$avail_roles =& $users_of_blog['avail_roles'];
   191 		$avail_roles =& $users_of_blog['avail_roles'];
   182 		unset($users_of_blog);
   192 		unset( $users_of_blog );
   183 
   193 
   184 		$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
   194 		$current_link_attributes = empty( $role ) ? ' class="current" aria-current="page"' : '';
   185 
   195 
   186 		$role_links = array();
   196 		$role_links        = array();
   187 		$role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
   197 		$role_links['all'] = "<a href='$url'$current_link_attributes>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users, 'users' ), number_format_i18n( $total_users ) ) . '</a>';
   188 		foreach ( $wp_roles->get_names() as $this_role => $name ) {
   198 		foreach ( $wp_roles->get_names() as $this_role => $name ) {
   189 			if ( !isset($avail_roles[$this_role]) )
   199 			if ( ! isset( $avail_roles[ $this_role ] ) ) {
   190 				continue;
   200 				continue;
       
   201 			}
   191 
   202 
   192 			$current_link_attributes = '';
   203 			$current_link_attributes = '';
   193 
   204 
   194 			if ( $this_role === $role ) {
   205 			if ( $this_role === $role ) {
   195 				$current_link_attributes = ' class="current" aria-current="page"';
   206 				$current_link_attributes = ' class="current" aria-current="page"';
   196 			}
   207 			}
   197 
   208 
   198 			$name = translate_user_role( $name );
   209 			$name = translate_user_role( $name );
   199 			/* translators: User role name with count */
   210 			/* translators: User role name with count */
   200 			$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles[$this_role] ) );
   211 			$name                     = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles[ $this_role ] ) );
   201 			$role_links[$this_role] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
   212 			$role_links[ $this_role ] = "<a href='" . esc_url( add_query_arg( 'role', $this_role, $url ) ) . "'$current_link_attributes>$name</a>";
   202 		}
   213 		}
   203 
   214 
   204 		if ( ! empty( $avail_roles['none' ] ) ) {
   215 		if ( ! empty( $avail_roles['none'] ) ) {
   205 
   216 
   206 			$current_link_attributes = '';
   217 			$current_link_attributes = '';
   207 
   218 
   208 			if ( 'none' === $role ) {
   219 			if ( 'none' === $role ) {
   209 				$current_link_attributes = ' class="current" aria-current="page"';
   220 				$current_link_attributes = ' class="current" aria-current="page"';
   210 			}
   221 			}
   211 
   222 
   212 			$name = __( 'No role' );
   223 			$name = __( 'No role' );
   213 			/* translators: User role name with count */
   224 			/* translators: User role name with count */
   214 			$name = sprintf( __('%1$s <span class="count">(%2$s)</span>'), $name, number_format_i18n( $avail_roles['none' ] ) );
   225 			$name               = sprintf( __( '%1$s <span class="count">(%2$s)</span>' ), $name, number_format_i18n( $avail_roles['none'] ) );
   215 			$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
   226 			$role_links['none'] = "<a href='" . esc_url( add_query_arg( 'role', 'none', $url ) ) . "'$current_link_attributes>$name</a>";
   216 
   227 
   217 		}
   228 		}
   218 
   229 
   219 		return $role_links;
   230 		return $role_links;
   228 	 */
   239 	 */
   229 	protected function get_bulk_actions() {
   240 	protected function get_bulk_actions() {
   230 		$actions = array();
   241 		$actions = array();
   231 
   242 
   232 		if ( is_multisite() ) {
   243 		if ( is_multisite() ) {
   233 			if ( current_user_can( 'remove_users' ) )
   244 			if ( current_user_can( 'remove_users' ) ) {
   234 				$actions['remove'] = __( 'Remove' );
   245 				$actions['remove'] = __( 'Remove' );
       
   246 			}
   235 		} else {
   247 		} else {
   236 			if ( current_user_can( 'delete_users' ) )
   248 			if ( current_user_can( 'delete_users' ) ) {
   237 				$actions['delete'] = __( 'Delete' );
   249 				$actions['delete'] = __( 'Delete' );
       
   250 			}
   238 		}
   251 		}
   239 
   252 
   240 		return $actions;
   253 		return $actions;
   241 	}
   254 	}
   242 
   255 
   247 	 *
   260 	 *
   248 	 * @param string $which Whether this is being invoked above ("top")
   261 	 * @param string $which Whether this is being invoked above ("top")
   249 	 *                      or below the table ("bottom").
   262 	 *                      or below the table ("bottom").
   250 	 */
   263 	 */
   251 	protected function extra_tablenav( $which ) {
   264 	protected function extra_tablenav( $which ) {
   252 		$id = 'bottom' === $which ? 'new_role2' : 'new_role';
   265 		$id        = 'bottom' === $which ? 'new_role2' : 'new_role';
   253 		$button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
   266 		$button_id = 'bottom' === $which ? 'changeit2' : 'changeit';
   254 	?>
   267 		?>
   255 	<div class="alignleft actions">
   268 	<div class="alignleft actions">
   256 		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
   269 		<?php if ( current_user_can( 'promote_users' ) && $this->has_items() ) : ?>
   257 		<label class="screen-reader-text" for="<?php echo $id ?>"><?php _e( 'Change role to&hellip;' ) ?></label>
   270 		<label class="screen-reader-text" for="<?php echo $id; ?>"><?php _e( 'Change role to&hellip;' ); ?></label>
   258 		<select name="<?php echo $id ?>" id="<?php echo $id ?>">
   271 		<select name="<?php echo $id; ?>" id="<?php echo $id; ?>">
   259 			<option value=""><?php _e( 'Change role to&hellip;' ) ?></option>
   272 			<option value=""><?php _e( 'Change role to&hellip;' ); ?></option>
   260 			<?php wp_dropdown_roles(); ?>
   273 			<?php wp_dropdown_roles(); ?>
   261 		</select>
   274 		</select>
   262 	<?php
   275 			<?php
   263 			submit_button( __( 'Change' ), '', $button_id, false );
   276 			submit_button( __( 'Change' ), '', $button_id, false );
   264 		endif;
   277 		endif;
   265 
   278 
   266 		/**
   279 		/**
   267 		 * Fires just before the closing div containing the bulk role-change controls
   280 		 * Fires just before the closing div containing the bulk role-change controls
   271 		 * @since 4.6.0 The `$which` parameter was added.
   284 		 * @since 4.6.0 The `$which` parameter was added.
   272 		 *
   285 		 *
   273 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
   286 		 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
   274 		 */
   287 		 */
   275 		do_action( 'restrict_manage_users', $which );
   288 		do_action( 'restrict_manage_users', $which );
   276 	?>
   289 		?>
   277 		</div>
   290 		</div>
   278 	<?php
   291 		<?php
   279 		/**
   292 		/**
   280 		 * Fires immediately following the closing "actions" div in the tablenav for the users
   293 		 * Fires immediately following the closing "actions" div in the tablenav for the users
   281 		 * list table.
   294 		 * list table.
   282 		 *
   295 		 *
   283 		 * @since 4.9.0
   296 		 * @since 4.9.0
   319 			'cb'       => '<input type="checkbox" />',
   332 			'cb'       => '<input type="checkbox" />',
   320 			'username' => __( 'Username' ),
   333 			'username' => __( 'Username' ),
   321 			'name'     => __( 'Name' ),
   334 			'name'     => __( 'Name' ),
   322 			'email'    => __( 'Email' ),
   335 			'email'    => __( 'Email' ),
   323 			'role'     => __( 'Role' ),
   336 			'role'     => __( 'Role' ),
   324 			'posts'    => __( 'Posts' )
   337 			'posts'    => __( 'Posts' ),
   325 		);
   338 		);
   326 
   339 
   327 		if ( $this->is_site_users )
   340 		if ( $this->is_site_users ) {
   328 			unset( $c['posts'] );
   341 			unset( $c['posts'] );
       
   342 		}
   329 
   343 
   330 		return $c;
   344 		return $c;
   331 	}
   345 	}
   332 
   346 
   333 	/**
   347 	/**
   351 	 *
   365 	 *
   352 	 * @since 3.1.0
   366 	 * @since 3.1.0
   353 	 */
   367 	 */
   354 	public function display_rows() {
   368 	public function display_rows() {
   355 		// Query the post counts for this page
   369 		// Query the post counts for this page
   356 		if ( ! $this->is_site_users )
   370 		if ( ! $this->is_site_users ) {
   357 			$post_counts = count_many_users_posts( array_keys( $this->items ) );
   371 			$post_counts = count_many_users_posts( array_keys( $this->items ) );
       
   372 		}
   358 
   373 
   359 		foreach ( $this->items as $userid => $user_object ) {
   374 		foreach ( $this->items as $userid => $user_object ) {
   360 			echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
   375 			echo "\n\t" . $this->single_row( $user_object, '', '', isset( $post_counts ) ? $post_counts[ $userid ] : 0 );
   361 		}
   376 		}
   362 	}
   377 	}
   378 	public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
   393 	public function single_row( $user_object, $style = '', $role = '', $numposts = 0 ) {
   379 		if ( ! ( $user_object instanceof WP_User ) ) {
   394 		if ( ! ( $user_object instanceof WP_User ) ) {
   380 			$user_object = get_userdata( (int) $user_object );
   395 			$user_object = get_userdata( (int) $user_object );
   381 		}
   396 		}
   382 		$user_object->filter = 'display';
   397 		$user_object->filter = 'display';
   383 		$email = $user_object->user_email;
   398 		$email               = $user_object->user_email;
   384 
   399 
   385 		if ( $this->is_site_users )
   400 		if ( $this->is_site_users ) {
   386 			$url = "site-users.php?id={$this->site_id}&amp;";
   401 			$url = "site-users.php?id={$this->site_id}&amp;";
   387 		else
   402 		} else {
   388 			$url = 'users.php?';
   403 			$url = 'users.php?';
       
   404 		}
   389 
   405 
   390 		$user_roles = $this->get_role_list( $user_object );
   406 		$user_roles = $this->get_role_list( $user_object );
   391 
   407 
   392 		// Set up the hover actions for this user
   408 		// Set up the hover actions for this user
   393 		$actions = array();
   409 		$actions     = array();
   394 		$checkbox = '';
   410 		$checkbox    = '';
   395 		$super_admin = '';
   411 		$super_admin = '';
   396 
   412 
   397 		if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
   413 		if ( is_multisite() && current_user_can( 'manage_network_users' ) ) {
   398 			if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
   414 			if ( in_array( $user_object->user_login, get_super_admins(), true ) ) {
   399 				$super_admin = ' &mdash; ' . __( 'Super Admin' );
   415 				$super_admin = ' &mdash; ' . __( 'Super Admin' );
   403 		// Check if the user for this row is editable
   419 		// Check if the user for this row is editable
   404 		if ( current_user_can( 'list_users' ) ) {
   420 		if ( current_user_can( 'list_users' ) ) {
   405 			// Set up the user editing link
   421 			// Set up the user editing link
   406 			$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
   422 			$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user_object->ID ) ) );
   407 
   423 
   408 			if ( current_user_can( 'edit_user',  $user_object->ID ) ) {
   424 			if ( current_user_can( 'edit_user', $user_object->ID ) ) {
   409 				$edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
   425 				$edit            = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
   410 				$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
   426 				$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
   411 			} else {
   427 			} else {
   412 				$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
   428 				$edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
   413 			}
   429 			}
   414 
   430 
   415 			if ( !is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) )
   431 			if ( ! is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'delete_user', $user_object->ID ) ) {
   416 				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . "</a>";
   432 				$actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
   417 			if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) )
   433 			}
   418 				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url."action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . "</a>";
   434 			if ( is_multisite() && get_current_user_id() != $user_object->ID && current_user_can( 'remove_user', $user_object->ID ) ) {
       
   435 				$actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
       
   436 			}
   419 
   437 
   420 			// Add a link to the user's author archive, if not empty.
   438 			// Add a link to the user's author archive, if not empty.
   421 			$author_posts_url = get_author_posts_url( $user_object->ID );
   439 			$author_posts_url = get_author_posts_url( $user_object->ID );
   422 			if ( $author_posts_url ) {
   440 			if ( $author_posts_url ) {
   423 				$actions['view'] = sprintf(
   441 				$actions['view'] = sprintf(
   432 			/**
   450 			/**
   433 			 * Filters the action links displayed under each user in the Users list table.
   451 			 * Filters the action links displayed under each user in the Users list table.
   434 			 *
   452 			 *
   435 			 * @since 2.8.0
   453 			 * @since 2.8.0
   436 			 *
   454 			 *
   437 			 * @param array   $actions     An array of action links to be displayed.
   455 			 * @param string[] $actions     An array of action links to be displayed.
   438 			 *                             Default 'Edit', 'Delete' for single site, and
   456 			 *                              Default 'Edit', 'Delete' for single site, and
   439 			 *                             'Edit', 'Remove' for Multisite.
   457 			 *                              'Edit', 'Remove' for Multisite.
   440 			 * @param WP_User $user_object WP_User object for the currently-listed user.
   458 			 * @param WP_User  $user_object WP_User object for the currently listed user.
   441 			 */
   459 			 */
   442 			$actions = apply_filters( 'user_row_actions', $actions, $user_object );
   460 			$actions = apply_filters( 'user_row_actions', $actions, $user_object );
   443 
   461 
   444 			// Role classes.
   462 			// Role classes.
   445 			$role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
   463 			$role_classes = esc_attr( implode( ' ', array_keys( $user_roles ) ) );
   526 				}
   544 				}
   527 
   545 
   528 				if ( $primary === $column_name ) {
   546 				if ( $primary === $column_name ) {
   529 					$r .= $this->row_actions( $actions );
   547 					$r .= $this->row_actions( $actions );
   530 				}
   548 				}
   531 				$r .= "</td>";
   549 				$r .= '</td>';
   532 			}
   550 			}
   533 		}
   551 		}
   534 		$r .= '</tr>';
   552 		$r .= '</tr>';
   535 
   553 
   536 		return $r;
   554 		return $r;
   551 	 * Returns an array of user roles for a given user object.
   569 	 * Returns an array of user roles for a given user object.
   552 	 *
   570 	 *
   553 	 * @since 4.4.0
   571 	 * @since 4.4.0
   554 	 *
   572 	 *
   555 	 * @param WP_User $user_object The WP_User object.
   573 	 * @param WP_User $user_object The WP_User object.
   556 	 * @return array An array of user roles.
   574 	 * @return string[] An array of user roles.
   557 	 */
   575 	 */
   558 	protected function get_role_list( $user_object ) {
   576 	protected function get_role_list( $user_object ) {
   559 		$wp_roles = wp_roles();
   577 		$wp_roles = wp_roles();
   560 
   578 
   561 		$role_list = array();
   579 		$role_list = array();
   573 		/**
   591 		/**
   574 		 * Filters the returned array of roles for a user.
   592 		 * Filters the returned array of roles for a user.
   575 		 *
   593 		 *
   576 		 * @since 4.4.0
   594 		 * @since 4.4.0
   577 		 *
   595 		 *
   578 		 * @param array   $role_list   An array of user roles.
   596 		 * @param string[] $role_list   An array of user roles.
   579 		 * @param WP_User $user_object A WP_User object.
   597 		 * @param WP_User  $user_object A WP_User object.
   580 		 */
   598 		 */
   581 		return apply_filters( 'get_role_list', $role_list, $user_object );
   599 		return apply_filters( 'get_role_list', $role_list, $user_object );
   582 	}
   600 	}
   583 
   601 
   584 }
   602 }