Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 49 additions & 14 deletions src/wp-admin/includes/class-wp-ms-users-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@
*/
class WP_MS_Users_List_Table extends WP_List_Table {
/**
* @return bool
* Checks if the current user has permissions to perform an Ajax action.
*
* @since 3.1.0
*
* @return bool Whether the current user can perform an Ajax action.
*/
public function ajax_user_can() {
return current_user_can( 'manage_network_users' );
}

/**
* Prepares the users list for display.
*
* @since 3.1.0
*
* @global string $mode List table view mode.
* @global string $usersearch
* @global string $role
* @global string $usersearch User search query.
* @global string $role The user role to filter by.
*/
public function prepare_items() {
global $mode, $usersearch, $role;
Expand Down Expand Up @@ -106,7 +114,11 @@ public function prepare_items() {
}

/**
* @return array
* Gets the available bulk actions for the users list table.
*
* @since 3.1.0
*
* @return array<string, string> An associative array of bulk actions.
*/
protected function get_bulk_actions() {
$actions = array();
Expand All @@ -120,14 +132,22 @@ protected function get_bulk_actions() {
}

/**
* Displays a message when there are no items.
*
* @since 3.1.0
*/
public function no_items() {
_e( 'No users found.' );
}

/**
* @global string $role
* @return array
* Gets the list of views (all, super admin) available for the users list table.
*
* @since 3.1.0
*
* @global string $role The user role to filter by.
*
* @return array<string, string> An associative array of views.
*/
protected function get_views() {
global $role;
Expand Down Expand Up @@ -170,9 +190,13 @@ protected function get_views() {
}

/**
* Generates the list table pagination.
*
* @since 3.1.0
*
* @global string $mode List table view mode.
*
* @param string $which
* @param string $which The location of the pagination: 'top' or 'bottom'.
*/
protected function pagination( $which ) {
global $mode;
Expand All @@ -185,7 +209,11 @@ protected function pagination( $which ) {
}

/**
* @return string[] Array of column titles keyed by their column name.
* Gets the list of columns for the users list table.
*
* @since 3.1.0
*
* @return array<string, string> Array of column titles keyed by their column name.
*/
public function get_columns() {
$users_columns = array(
Expand All @@ -202,13 +230,18 @@ public function get_columns() {
* @since MU (3.0.0)
*
* @param string[] $users_columns An array of user columns. Default 'cb', 'username',
* 'name', 'email', 'registered', 'blogs'.
* @param array<string, string> $users_columns An array of user columns. Default 'cb', 'username',
* 'name', 'email', 'registered', 'blogs'.
*/
return apply_filters( 'wpmu_users_columns', $users_columns );
}

/**
* @return array
* Gets the list of sortable columns for the users list table.
*
* @since 3.1.0
*
* @return array<string, array{0: string, 1: bool, 2: string, 3: string, 4?: string}> Sortable columns.
*/
protected function get_sortable_columns() {
return array(
Expand Down Expand Up @@ -349,12 +382,14 @@ public function column_registered( $user ) {
}

/**
* Outputs the sites column content.
*
* @since 4.3.0
*
* @param WP_User $user
* @param string $classes
* @param string $data
* @param string $primary
* @param WP_User $user The current WP_User object.
* @param string $classes CSS classes for the cell.
* @param string $data Custom data attributes for the cell.
* @param string $primary The primary column name.
*/
protected function _column_blogs( $user, $classes, $data, $primary ) {
echo '<td class="', $classes, ' has-row-actions" ', $data, '>';
Expand Down
67 changes: 50 additions & 17 deletions src/wp-admin/includes/class-wp-plugin-install-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
private $error;

/**
* @return bool
* Checks if the current user has permissions to perform an Ajax action.
*
* @since 3.1.0
*
* @return bool Whether the current user can perform an Ajax action.
*/
public function ajax_user_can() {
return current_user_can( 'install_plugins' );
Expand Down Expand Up @@ -80,11 +84,15 @@ protected function get_installed_plugin_slugs() {
}

/**
* @global array $tabs
* @global string $tab
* @global int $paged
* @global string $type
* @global string $term
* Prepares the plugins list for display.
*
* @since 3.1.0
*
* @global array $tabs The tabs shown on the Add Plugins screen.
* @global string $tab The current active tab.
* @global int $paged The current page number.
* @global string $type The type of search being performed.
* @global string $term The search term.
*/
public function prepare_items() {
require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
Expand Down Expand Up @@ -287,6 +295,9 @@ public function prepare_items() {
}

/**
* Outputs the message when no plugins are found.
*
* @since 3.1.0
*/
public function no_items() {
if ( isset( $this->error ) ) {
Expand All @@ -307,10 +318,14 @@ public function no_items() {
}

/**
* @global array $tabs
* @global string $tab
* Gets the list of views (tabs) available for the plugins list table.
*
* @return array
* @since 3.1.0
*
* @global array<string, string> $tabs The tabs shown on the Add Plugins screen.
* @global string $tab The current active tab.
*
* @return array<string, string> Array of view links keyed by their ID.
*/
protected function get_views() {
global $tabs, $tab;
Expand All @@ -330,7 +345,9 @@ protected function get_views() {
}

/**
* Overrides parent views so we can use the filter bar display.
* Displays the view (tabs) switcher for the plugins list table.
*
* @since 3.1.0
*/
public function views() {
$views = $this->get_views();
Expand Down Expand Up @@ -395,9 +412,13 @@ public function display() {
}

/**
* @global string $tab
* Generates the table navigation.
*
* @param string $which
* @since 3.1.0
*
* @global string $tab The current active tab.
*
* @param string $which The location of the pagination: 'top' or 'bottom'.
*/
protected function display_tablenav( $which ) {
if ( 'featured' === $GLOBALS['tab'] ) {
Expand Down Expand Up @@ -431,23 +452,35 @@ protected function display_tablenav( $which ) {
}

/**
* @return array
* Gets the list of CSS classes for the table container.
*
* @since 3.1.0
*
* @return string[] CSS classes.
*/
protected function get_table_classes() {
return array( 'widefat', $this->_args['plural'] );
}

/**
* @return string[] Array of column titles keyed by their column name.
* Gets the list of columns for the plugins list table.
*
* @since 3.1.0
*
* @return array<string, string> Array of column titles keyed by their column name.
*/
public function get_columns() {
return array();
}

/**
* @param object $plugin_a
* @param object $plugin_b
* @return int
* Callback for sorting plugins.
*
* @since 3.1.0
*
* @param object $plugin_a The first plugin object.
* @param object $plugin_b The second plugin object.
* @return int Comparison result.
*/
private function order_callback( $plugin_a, $plugin_b ) {
$orderby = $this->orderby;
Expand Down
Loading