2010-10-24 22:57:43 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2015-10-17 11:13:25 -04:00
|
|
|
* List Table API: WP_MS_Users_List_Table class
|
2010-10-24 22:57:43 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
2015-10-17 11:13:25 -04:00
|
|
|
* @subpackage Administration
|
|
|
|
* @since 3.1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Core class used to implement displaying users in a list table for the network admin.
|
|
|
|
*
|
2010-10-25 00:04:18 -04:00
|
|
|
* @since 3.1.0
|
2015-10-17 11:13:25 -04:00
|
|
|
*
|
|
|
|
* @see WP_List_Table
|
2010-10-24 22:57:43 -04:00
|
|
|
*/
|
2010-11-04 04:07:03 -04:00
|
|
|
class WP_MS_Users_List_Table extends WP_List_Table {
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function ajax_user_can() {
|
2010-12-16 04:18:28 -05:00
|
|
|
return current_user_can( 'manage_network_users' );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
2020-07-10 12:04:05 -04:00
|
|
|
* @global string $mode List table view mode.
|
2015-05-28 17:41:30 -04:00
|
|
|
* @global string $usersearch
|
|
|
|
* @global string $role
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function prepare_items() {
|
2020-07-10 12:04:05 -04:00
|
|
|
global $mode, $usersearch, $role;
|
|
|
|
|
|
|
|
if ( ! empty( $_REQUEST['mode'] ) ) {
|
|
|
|
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list';
|
|
|
|
set_user_setting( 'network_users_list_mode', $mode );
|
|
|
|
} else {
|
|
|
|
$mode = get_user_setting( 'network_users_list_mode', 'list' );
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2014-02-02 17:10:12 -05:00
|
|
|
$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
|
|
|
|
|
2010-11-10 12:05:20 -05:00
|
|
|
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
|
|
|
|
|
2010-10-24 22:57:43 -04:00
|
|
|
$paged = $this->get_pagenum();
|
|
|
|
|
|
|
|
$args = array(
|
2017-11-30 18:11:00 -05:00
|
|
|
'number' => $users_per_page,
|
|
|
|
'offset' => ( $paged - 1 ) * $users_per_page,
|
|
|
|
'search' => $usersearch,
|
2010-12-16 19:38:15 -05:00
|
|
|
'blog_id' => 0,
|
2017-11-30 18:11:00 -05:00
|
|
|
'fields' => 'all_with_meta',
|
2010-10-24 22:57:43 -04:00
|
|
|
);
|
|
|
|
|
2015-08-28 20:19:24 -04:00
|
|
|
if ( wp_is_large_network( 'users' ) ) {
|
2011-10-03 12:30:07 -04:00
|
|
|
$args['search'] = ltrim( $args['search'], '*' );
|
2017-11-30 18:11:00 -05:00
|
|
|
} elseif ( '' !== $args['search'] ) {
|
2015-08-28 20:19:24 -04:00
|
|
|
$args['search'] = trim( $args['search'], '*' );
|
|
|
|
$args['search'] = '*' . $args['search'] . '*';
|
|
|
|
}
|
2010-12-30 18:38:21 -05:00
|
|
|
|
2020-02-09 11:55:09 -05:00
|
|
|
if ( 'super' === $role ) {
|
2019-03-07 07:35:52 -05:00
|
|
|
$args['login__in'] = get_super_admins();
|
2010-11-10 12:05:20 -05:00
|
|
|
}
|
|
|
|
|
2014-07-17 05:14:16 -04:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! $usersearch && wp_is_large_network( 'users' ) ) {
|
|
|
|
if ( ! isset( $_REQUEST['orderby'] ) ) {
|
2019-07-01 08:52:01 -04:00
|
|
|
$_GET['orderby'] = 'id';
|
|
|
|
$_REQUEST['orderby'] = 'id';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
|
|
|
if ( ! isset( $_REQUEST['order'] ) ) {
|
2019-07-01 08:52:01 -04:00
|
|
|
$_GET['order'] = 'DESC';
|
|
|
|
$_REQUEST['order'] = 'DESC';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-11-03 09:34:04 -04:00
|
|
|
$args['count_total'] = false;
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['orderby'] ) ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
$args['orderby'] = $_REQUEST['orderby'];
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['order'] ) ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
$args['order'] = $_REQUEST['order'];
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-10-03 03:24:25 -04:00
|
|
|
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
|
2015-10-03 17:49:24 -04:00
|
|
|
$args = apply_filters( 'users_list_table_query_args', $args );
|
2015-10-03 03:24:25 -04:00
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Query the user IDs for this page.
|
2010-10-24 22:57:43 -04:00
|
|
|
$wp_user_search = new WP_User_Query( $args );
|
|
|
|
|
|
|
|
$this->items = $wp_user_search->get_results();
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->set_pagination_args(
|
|
|
|
array(
|
|
|
|
'total_items' => $wp_user_search->get_total(),
|
|
|
|
'per_page' => $users_per_page,
|
|
|
|
)
|
|
|
|
);
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_bulk_actions() {
|
2010-10-24 22:57:43 -04:00
|
|
|
$actions = array();
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( current_user_can( 'delete_users' ) ) {
|
2010-11-12 11:00:41 -05:00
|
|
|
$actions['delete'] = __( 'Delete' );
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2020-07-23 20:27:03 -04:00
|
|
|
$actions['spam'] = _x( 'Mark as spam', 'user' );
|
|
|
|
$actions['notspam'] = _x( 'Not spam', 'user' );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2015-05-29 17:32:24 -04:00
|
|
|
/**
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function no_items() {
|
2010-10-24 22:57:43 -04:00
|
|
|
_e( 'No users found.' );
|
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
|
|
|
* @global string $role
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_views() {
|
2014-05-06 11:30:14 -04:00
|
|
|
global $role;
|
2010-11-10 12:05:20 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$total_users = get_user_count();
|
2010-11-10 12:05:20 -05:00
|
|
|
$super_admins = get_super_admins();
|
|
|
|
$total_admins = count( $super_admins );
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
$role_links = array();
|
|
|
|
$role_links['all'] = array(
|
|
|
|
'url' => network_admin_url( 'users.php' ),
|
|
|
|
'label' => sprintf(
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: Number of users. */
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
_nx(
|
|
|
|
'All <span class="count">(%s)</span>',
|
|
|
|
'All <span class="count">(%s)</span>',
|
|
|
|
$total_users,
|
|
|
|
'users'
|
|
|
|
),
|
|
|
|
number_format_i18n( $total_users )
|
2022-09-19 17:08:10 -04:00
|
|
|
),
|
|
|
|
'current' => 'super' !== $role,
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
);
|
2022-09-19 17:08:10 -04:00
|
|
|
|
|
|
|
$role_links['super'] = array(
|
|
|
|
'url' => network_admin_url( 'users.php?role=super' ),
|
|
|
|
'label' => sprintf(
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: Number of users. */
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
_n(
|
|
|
|
'Super Admin <span class="count">(%s)</span>',
|
|
|
|
'Super Admins <span class="count">(%s)</span>',
|
|
|
|
$total_admins
|
|
|
|
),
|
|
|
|
number_format_i18n( $total_admins )
|
2022-09-19 17:08:10 -04:00
|
|
|
),
|
|
|
|
'current' => 'super' === $role,
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
);
|
2010-11-10 12:05:20 -05:00
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
return $this->get_views_links( $role_links );
|
2010-11-10 12:05:20 -05:00
|
|
|
}
|
|
|
|
|
2014-11-30 19:33:23 -05:00
|
|
|
/**
|
2017-03-21 23:48:42 -04:00
|
|
|
* @global string $mode List table view mode.
|
|
|
|
*
|
2014-11-30 19:33:23 -05:00
|
|
|
* @param string $which
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function pagination( $which ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
global $mode;
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
parent::pagination( $which );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-09-22 02:06:25 -04:00
|
|
|
if ( 'top' === $which ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
$this->view_switcher( $mode );
|
2015-09-22 02:06:25 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
2023-05-08 18:37:24 -04:00
|
|
|
* @return string[] Array of column titles keyed by their column name.
|
2015-05-29 16:17:26 -04:00
|
|
|
*/
|
2014-07-11 23:27:14 -04:00
|
|
|
public function get_columns() {
|
2010-10-24 22:57:43 -04:00
|
|
|
$users_columns = array(
|
|
|
|
'cb' => '<input type="checkbox" />',
|
2010-11-28 12:39:44 -05:00
|
|
|
'username' => __( 'Username' ),
|
2010-10-24 22:57:43 -04:00
|
|
|
'name' => __( 'Name' ),
|
2015-08-27 23:17:21 -04:00
|
|
|
'email' => __( 'Email' ),
|
2010-10-24 22:57:43 -04:00
|
|
|
'registered' => _x( 'Registered', 'user' ),
|
2017-11-30 18:11:00 -05:00
|
|
|
'blogs' => __( 'Sites' ),
|
2010-10-24 22:57:43 -04:00
|
|
|
);
|
2013-11-23 17:25:10 -05:00
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the columns displayed in the Network Admin Users list table.
|
2013-11-23 17:25:10 -05:00
|
|
|
*
|
2017-08-01 16:44:43 -04:00
|
|
|
* @since MU (3.0.0)
|
2013-11-23 17:25:10 -05:00
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $users_columns An array of user columns. Default 'cb', 'username',
|
|
|
|
* 'name', 'email', 'registered', 'blogs'.
|
2013-11-23 17:25:10 -05:00
|
|
|
*/
|
2015-05-29 16:17:26 -04:00
|
|
|
return apply_filters( 'wpmu_users_columns', $users_columns );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_sortable_columns() {
|
2010-10-24 22:57:43 -04:00
|
|
|
return array(
|
2023-06-21 17:47:23 -04:00
|
|
|
'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ),
|
|
|
|
'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ),
|
|
|
|
'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ),
|
|
|
|
'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ),
|
2010-10-24 22:57:43 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the checkbox column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
* @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-06-13 13:11:26 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
* @param WP_User $item The current WP_User object.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
public function column_cb( $item ) {
|
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
|
|
|
$user = $item;
|
|
|
|
|
2015-08-27 23:49:21 -04:00
|
|
|
if ( is_super_admin( $user->ID ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2015-06-13 13:11:26 -04:00
|
|
|
?>
|
2023-09-22 15:58:16 -04:00
|
|
|
<input type="checkbox" id="blog_<?php echo $user->ID; ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ); ?>" />
|
|
|
|
<label for="blog_<?php echo $user->ID; ?>">
|
2023-06-20 21:54:19 -04:00
|
|
|
<span class="screen-reader-text">
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
<?php
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
/* translators: Hidden accessibility text. %s: User login. */
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
printf( __( 'Select %s' ), $user->user_login );
|
|
|
|
?>
|
2023-06-20 21:54:19 -04:00
|
|
|
</span>
|
2019-07-09 17:11:58 -04:00
|
|
|
</label>
|
2015-06-13 13:11:26 -04:00
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2015-09-18 11:58:25 -04:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2015-06-13 13:11:26 -04:00
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the username column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-13 13:43:25 -04:00
|
|
|
* @param WP_User $user The current WP_User object.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
|
|
|
public function column_username( $user ) {
|
|
|
|
$super_admins = get_super_admins();
|
2017-11-30 18:11:00 -05:00
|
|
|
$avatar = get_avatar( $user->user_email, 32 );
|
2015-06-13 13:11:26 -04:00
|
|
|
|
|
|
|
echo $avatar;
|
|
|
|
|
2017-11-17 16:35:51 -05:00
|
|
|
if ( current_user_can( 'edit_user', $user->ID ) ) {
|
|
|
|
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
2017-11-30 18:11:00 -05:00
|
|
|
$edit = "<a href=\"{$edit_link}\">{$user->user_login}</a>";
|
2017-11-17 16:35:51 -05:00
|
|
|
} else {
|
|
|
|
$edit = $user->user_login;
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
2017-11-17 16:35:51 -05:00
|
|
|
|
|
|
|
?>
|
|
|
|
<strong>
|
|
|
|
<?php
|
|
|
|
echo $edit;
|
|
|
|
|
2020-04-04 23:02:11 -04:00
|
|
|
if ( in_array( $user->user_login, $super_admins, true ) ) {
|
2017-11-17 16:35:51 -05:00
|
|
|
echo ' — ' . __( 'Super Admin' );
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</strong>
|
|
|
|
<?php
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the name column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-13 13:43:25 -04:00
|
|
|
* @param WP_User $user The current WP_User object.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
|
|
|
public function column_name( $user ) {
|
2017-06-26 20:27:39 -04:00
|
|
|
if ( $user->first_name && $user->last_name ) {
|
2022-06-14 10:43:12 -04:00
|
|
|
printf(
|
|
|
|
/* translators: 1: User's first name, 2: Last name. */
|
|
|
|
_x( '%1$s %2$s', 'Display name based on first name and last name' ),
|
|
|
|
$user->first_name,
|
|
|
|
$user->last_name
|
|
|
|
);
|
2017-11-29 10:28:53 -05:00
|
|
|
} elseif ( $user->first_name ) {
|
|
|
|
echo $user->first_name;
|
|
|
|
} elseif ( $user->last_name ) {
|
|
|
|
echo $user->last_name;
|
2017-06-26 20:27:39 -04:00
|
|
|
} else {
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' .
|
|
|
|
/* translators: Hidden accessibility text. */
|
|
|
|
_x( 'Unknown', 'name' ) .
|
|
|
|
'</span>';
|
2017-06-26 20:27:39 -04:00
|
|
|
}
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the email column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-13 13:43:25 -04:00
|
|
|
* @param WP_User $user The current WP_User object.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
|
|
|
public function column_email( $user ) {
|
2015-09-14 18:33:25 -04:00
|
|
|
echo "<a href='" . esc_url( "mailto:$user->user_email" ) . "'>$user->user_email</a>";
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the registered date column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
2015-05-28 17:41:30 -04:00
|
|
|
*
|
2017-03-21 23:48:42 -04:00
|
|
|
* @global string $mode List table view mode.
|
2015-06-13 13:11:26 -04:00
|
|
|
*
|
2015-07-13 13:43:25 -04:00
|
|
|
* @param WP_User $user The current WP_User object.
|
2015-05-28 17:41:30 -04:00
|
|
|
*/
|
2015-06-13 13:11:26 -04:00
|
|
|
public function column_registered( $user ) {
|
2013-11-12 22:23:10 -05:00
|
|
|
global $mode;
|
2015-09-22 02:06:25 -04:00
|
|
|
if ( 'list' === $mode ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
$date = __( 'Y/m/d' );
|
|
|
|
} else {
|
|
|
|
$date = __( 'Y/m/d g:i:s a' );
|
|
|
|
}
|
|
|
|
echo mysql2date( $date, $user->user_registered );
|
|
|
|
}
|
|
|
|
|
2015-07-14 13:47:24 -04:00
|
|
|
/**
|
|
|
|
* @since 4.3.0
|
|
|
|
*
|
|
|
|
* @param WP_User $user
|
|
|
|
* @param string $classes
|
|
|
|
* @param string $data
|
|
|
|
* @param string $primary
|
|
|
|
*/
|
|
|
|
protected function _column_blogs( $user, $classes, $data, $primary ) {
|
|
|
|
echo '<td class="', $classes, ' has-row-actions" ', $data, '>';
|
|
|
|
echo $this->column_blogs( $user );
|
|
|
|
echo $this->handle_row_actions( $user, 'blogs', $primary );
|
|
|
|
echo '</td>';
|
|
|
|
}
|
|
|
|
|
2015-06-13 13:11:26 -04:00
|
|
|
/**
|
2016-01-27 22:35:27 -05:00
|
|
|
* Handles the sites column output.
|
2015-07-13 13:43:25 -04:00
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-13 13:43:25 -04:00
|
|
|
* @param WP_User $user The current WP_User object.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
|
|
|
public function column_blogs( $user ) {
|
|
|
|
$blogs = get_blogs_of_user( $user->ID, true );
|
|
|
|
if ( ! is_array( $blogs ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-01-16 03:40:00 -05:00
|
|
|
foreach ( $blogs as $site ) {
|
|
|
|
if ( ! can_edit_network( $site->site_id ) ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-01-16 03:40:00 -05:00
|
|
|
$path = ( '/' === $site->path ) ? '' : $site->path;
|
|
|
|
$site_classes = array( 'site-' . $site->site_id );
|
2023-11-15 04:33:26 -05:00
|
|
|
|
2019-03-21 19:55:51 -04:00
|
|
|
/**
|
2023-11-15 04:33:26 -05:00
|
|
|
* Filters the span class for a site listing on the multisite user list table.
|
2019-03-21 19:55:51 -04:00
|
|
|
*
|
|
|
|
* @since 5.2.0
|
|
|
|
*
|
2023-11-15 04:33:26 -05:00
|
|
|
* @param string[] $site_classes Array of class names used within the span tag.
|
|
|
|
* Default "site-#" with the site's network ID.
|
2019-10-26 17:09:04 -04:00
|
|
|
* @param int $site_id Site ID.
|
|
|
|
* @param int $network_id Network ID.
|
|
|
|
* @param WP_User $user WP_User object.
|
2019-03-21 19:55:51 -04:00
|
|
|
*/
|
2022-01-16 03:40:00 -05:00
|
|
|
$site_classes = apply_filters( 'ms_user_list_site_class', $site_classes, $site->userblog_id, $site->site_id, $user );
|
2023-11-15 04:33:26 -05:00
|
|
|
|
2019-03-21 19:55:51 -04:00
|
|
|
if ( is_array( $site_classes ) && ! empty( $site_classes ) ) {
|
|
|
|
$site_classes = array_map( 'sanitize_html_class', array_unique( $site_classes ) );
|
2019-04-19 09:51:51 -04:00
|
|
|
echo '<span class="' . esc_attr( implode( ' ', $site_classes ) ) . '">';
|
2019-03-21 19:55:51 -04:00
|
|
|
} else {
|
|
|
|
echo '<span>';
|
|
|
|
}
|
2023-11-15 04:33:26 -05:00
|
|
|
|
2022-01-16 03:40:00 -05:00
|
|
|
echo '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . str_replace( '.' . get_network()->domain, '', $site->domain . $path ) . '</a>';
|
2015-06-13 13:11:26 -04:00
|
|
|
echo ' <small class="row-actions">';
|
2023-11-15 04:33:26 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$actions = array();
|
2022-01-16 03:40:00 -05:00
|
|
|
$actions['edit'] = '<a href="' . esc_url( network_admin_url( 'site-info.php?id=' . $site->userblog_id ) ) . '">' . __( 'Edit' ) . '</a>';
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-01-14 17:14:22 -05:00
|
|
|
$class = '';
|
2022-01-16 03:40:00 -05:00
|
|
|
if ( 1 === (int) $site->spam ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
$class .= 'site-spammed ';
|
|
|
|
}
|
2022-01-16 03:40:00 -05:00
|
|
|
if ( 1 === (int) $site->mature ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
$class .= 'site-mature ';
|
|
|
|
}
|
2022-01-16 03:40:00 -05:00
|
|
|
if ( 1 === (int) $site->deleted ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
$class .= 'site-deleted ';
|
|
|
|
}
|
2022-01-16 03:40:00 -05:00
|
|
|
if ( 1 === (int) $site->archived ) {
|
2015-06-13 13:11:26 -04:00
|
|
|
$class .= 'site-archived ';
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2022-01-16 03:40:00 -05:00
|
|
|
$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $site->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
|
2015-06-13 13:11:26 -04:00
|
|
|
|
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the action links displayed next the sites a user belongs to
|
2015-06-13 13:11:26 -04:00
|
|
|
* in the Network Admin Users list table.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $actions An array of action links to be displayed. Default 'Edit', 'View'.
|
|
|
|
* @param int $userblog_id The site ID.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
2022-01-16 03:40:00 -05:00
|
|
|
$actions = apply_filters( 'ms_user_list_site_actions', $actions, $site->userblog_id );
|
2015-06-13 13:11:26 -04:00
|
|
|
|
|
|
|
$action_count = count( $actions );
|
2020-07-10 12:04:05 -04:00
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
2015-06-13 13:11:26 -04:00
|
|
|
foreach ( $actions as $action => $link ) {
|
|
|
|
++$i;
|
2020-07-10 12:04:05 -04:00
|
|
|
|
Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.
* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.
This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`
Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].
Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071
git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 13:19:09 -04:00
|
|
|
$separator = ( $i < $action_count ) ? ' | ' : '';
|
2020-07-10 12:04:05 -04:00
|
|
|
|
Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.
* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.
This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`
Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].
Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071
git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 13:19:09 -04:00
|
|
|
echo "<span class='$action'>{$link}{$separator}</span>";
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
2020-07-10 12:04:05 -04:00
|
|
|
|
2022-09-02 02:51:13 -04:00
|
|
|
echo '</small></span><br />';
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 13:11:26 -04:00
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Handles the default column output.
|
|
|
|
*
|
2015-06-13 13:11:26 -04:00
|
|
|
* @since 4.3.0
|
2021-09-07 12:57:58 -04:00
|
|
|
* @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-06-13 13:11:26 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_default()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51728
git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 18:26:56 -04:00
|
|
|
* @param WP_User $item The current WP_User object.
|
2020-07-23 16:01:04 -04:00
|
|
|
* @param string $column_name The current column name.
|
2015-06-13 13:11:26 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_default()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51728
git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 18:26:56 -04:00
|
|
|
public function column_default( $item, $column_name ) {
|
2023-09-14 08:46:20 -04:00
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
|
|
|
$user = $item;
|
|
|
|
|
2015-06-13 13:11:26 -04:00
|
|
|
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
|
2023-09-14 08:46:20 -04:00
|
|
|
echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
|
2024-07-17 11:43:15 -04:00
|
|
|
/**
|
|
|
|
* Generates the list table rows.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*/
|
2015-06-13 13:11:26 -04:00
|
|
|
public function display_rows() {
|
|
|
|
foreach ( $this->items as $user ) {
|
|
|
|
$class = '';
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$status_list = array(
|
|
|
|
'spam' => 'site-spammed',
|
|
|
|
'deleted' => 'site-deleted',
|
|
|
|
);
|
2015-06-13 13:11:26 -04:00
|
|
|
|
|
|
|
foreach ( $status_list as $status => $col ) {
|
|
|
|
if ( $user->$status ) {
|
|
|
|
$class .= " $col";
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2015-06-13 13:11:26 -04:00
|
|
|
}
|
|
|
|
|
2010-10-24 22:57:43 -04:00
|
|
|
?>
|
2015-06-13 13:11:26 -04:00
|
|
|
<tr class="<?php echo trim( $class ); ?>">
|
|
|
|
<?php $this->single_row_columns( $user ); ?>
|
2010-10-24 22:57:43 -04:00
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
2015-05-28 22:41:25 -04:00
|
|
|
|
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Gets the name of the default primary column.
|
2015-05-28 22:41:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-05-30 21:38:26 -04:00
|
|
|
* @return string Name of the default primary column, in this case, 'username'.
|
2015-05-28 22:41:25 -04:00
|
|
|
*/
|
|
|
|
protected function get_default_primary_column_name() {
|
|
|
|
return 'username';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-13 13:43:25 -04:00
|
|
|
* Generates and displays row action links.
|
2015-05-28 22:41:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
* @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-05-28 22:41:25 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
* @param WP_User $item User being acted upon.
|
2020-10-17 12:05:09 -04:00
|
|
|
* @param string $column_name Current column name.
|
|
|
|
* @param string $primary Primary column name.
|
2020-01-11 12:59:04 -05:00
|
|
|
* @return string Row actions output for users in Multisite, or an empty string
|
|
|
|
* if the current column is not the primary column.
|
2015-05-28 22:41:25 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
protected function handle_row_actions( $item, $column_name, $primary ) {
|
2015-07-14 13:47:24 -04:00
|
|
|
if ( $primary !== $column_name ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
2023-09-14 08:46:20 -04:00
|
|
|
$user = $item;
|
2015-05-28 22:41:25 -04:00
|
|
|
|
2023-09-14 08:46:20 -04:00
|
|
|
$super_admins = get_super_admins();
|
|
|
|
$actions = array();
|
2017-11-17 16:35:51 -05:00
|
|
|
|
|
|
|
if ( current_user_can( 'edit_user', $user->ID ) ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
2017-11-17 16:35:51 -05:00
|
|
|
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
|
|
|
}
|
2015-05-28 22:41:25 -04:00
|
|
|
|
2020-04-09 11:43:10 -04:00
|
|
|
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins, true ) ) {
|
2019-07-01 08:52:01 -04:00
|
|
|
$actions['delete'] = '<a href="' . esc_url( network_admin_url( add_query_arg( '_wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'users.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
2015-05-28 22:41:25 -04:00
|
|
|
}
|
2015-07-14 13:47:24 -04:00
|
|
|
|
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the action links displayed under each user in the Network Admin Users list table.
|
2015-07-14 13:47:24 -04:00
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $actions An array of action links to be displayed. Default 'Edit', 'Delete'.
|
|
|
|
* @param WP_User $user WP_User object.
|
2015-07-14 13:47:24 -04:00
|
|
|
*/
|
|
|
|
$actions = apply_filters( 'ms_user_row_actions', $actions, $user );
|
2020-01-11 12:59:04 -05:00
|
|
|
|
2015-07-14 13:47:24 -04:00
|
|
|
return $this->row_actions( $actions );
|
2015-05-28 22:41:25 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|