<?php /** * List Table API: WP_MS_Users_List_Table class * * @package WordPress * @subpackage Administration * @since 3.1.0 */
/** * Core class used to implement displaying users in a list table for the network admin. * * @since 3.1.0 * * @see WP_List_Table */ class WP_MS_Users_List_Table extends WP_List_Table { /** * @return bool */ public function ajax_user_can() { return current_user_can( 'manage_network_users' ); }
/** * @global string $mode List table view mode. * @global string $usersearch * @global string $role */ public function prepare_items() { global $mode, $usersearch, $role;
/* * If the network is large and a search is not being performed, * show only the latest users with no paging in order to avoid * expensive count queries. */ if ( ! $usersearch && wp_is_large_network( 'users' ) ) { if ( ! isset( $_REQUEST['orderby'] ) ) { $_GET['orderby'] = 'id'; $_REQUEST['orderby'] = 'id'; } if ( ! isset( $_REQUEST['order'] ) ) { $_GET['order'] = 'DESC'; $_REQUEST['order'] = 'DESC'; } $args['count_total'] = false; }
/** * Handles the checkbox column output. * * @since 4.3.0 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. * * @param WP_User $item The current WP_User object. */ public function column_cb( $item ) { // Restores the more descriptive, specific name for use within this method. $user = $item;
/** * Handles the ID column output. * * @since 4.4.0 * * @param WP_User $user The current WP_User object. */ public function column_id( $user ) { echo $user->ID; }
/** * Handles the username column output. * * @since 4.3.0 * * @param WP_User $user The current WP_User object. */ public function column_username( $user ) { $super_admins = get_super_admins(); $avatar = get_avatar( $user->user_email, 32 );
/** * Filters the span class for a site listing on the multisite user list table. * * @since 5.2.0 * * @param string[] $site_classes Array of class names used within the span tag. * Default "site-#" with the site's network ID. * @param int $site_id Site ID. * @param int $network_id Network ID. * @param WP_User $user WP_User object. */ $site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $site->userblog_id, $site->site_id, $user );
/** * Filters the action links displayed next the sites a user belongs to * in the Network Admin Users list table. * * @since 3.1.0 * * @param string[] $actions An array of action links to be displayed. Default 'Edit', 'View'. * @param int $userblog_id The site ID. */ $actions = apply_filters( 'ms_user_list_site_actions', $actions, $site->userblog_id );
/** * Handles the default column output. * * @since 4.3.0 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. * * @param WP_User $item The current WP_User object. * @param string $column_name The current column name. */ public function column_default( $item, $column_name ) { // Restores the more descriptive, specific name for use within this method. $user = $item;
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID ); }
/** * Generates the list table rows. * * @since 3.1.0 */ public function display_rows() { foreach ( $this->items as $user ) { $class = '';
/** * Gets the name of the default primary column. * * @since 4.3.0 * * @return string Name of the default primary column, in this case, 'username'. */ protected function get_default_primary_column_name() { return 'username'; }
/** * Generates and displays row action links. * * @since 4.3.0 * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support. * * @param WP_User $item User being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. * @return string Row actions output for users in Multisite, or an empty string * if the current column is not the primary column. */ protected function handle_row_actions( $item, $column_name, $primary ) { if ( $primary !== $column_name ) { return ''; }
// Restores the more descriptive, specific name for use within this method. $user = $item;
/** * Filters the action links displayed under each user in the Network Admin Users list table. * * @since 3.2.0 * * @param string[] $actions An array of action links to be displayed. Default 'Edit', 'Delete'. * @param WP_User $user WP_User object. */ $actions = apply_filters( 'ms_user_row_actions', $actions, $user );