2010-10-25 04:57:43 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2010-10-25 06:04:18 +02:00
|
|
|
* Multisite Users List Table class.
|
2010-10-25 04:57:43 +02:00
|
|
|
*
|
|
|
|
* @package WordPress
|
2010-10-25 06:04:18 +02:00
|
|
|
* @subpackage List_Table
|
|
|
|
* @since 3.1.0
|
2011-01-16 22:47:24 +01:00
|
|
|
* @access private
|
2010-10-25 04:57:43 +02:00
|
|
|
*/
|
2010-11-04 09:07:03 +01:00
|
|
|
class WP_MS_Users_List_Table extends WP_List_Table {
|
2015-05-29 22:17:26 +02: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-19 03:17:15 +02:00
|
|
|
public function ajax_user_can() {
|
2010-12-16 10:18:28 +01:00
|
|
|
return current_user_can( 'manage_network_users' );
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|
|
|
|
|
2015-05-28 23:41:30 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @global string $usersearch
|
|
|
|
* @global string $role
|
|
|
|
* @global wpdb $wpdb
|
|
|
|
* @global string $mode
|
|
|
|
*/
|
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-19 03:17:15 +02:00
|
|
|
public function prepare_items() {
|
2010-11-28 18:39:44 +01:00
|
|
|
global $usersearch, $role, $wpdb, $mode;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
2014-02-02 23:10:12 +01:00
|
|
|
$usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
|
2010-10-25 04:57:43 +02:00
|
|
|
|
|
|
|
$users_per_page = $this->get_items_per_page( 'users_network_per_page' );
|
|
|
|
|
2010-11-10 18:05:20 +01:00
|
|
|
$role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : '';
|
|
|
|
|
2010-10-25 04:57:43 +02:00
|
|
|
$paged = $this->get_pagenum();
|
|
|
|
|
|
|
|
$args = array(
|
|
|
|
'number' => $users_per_page,
|
|
|
|
'offset' => ( $paged-1 ) * $users_per_page,
|
|
|
|
'search' => $usersearch,
|
2010-12-17 01:38:15 +01:00
|
|
|
'blog_id' => 0,
|
|
|
|
'fields' => 'all_with_meta'
|
2010-10-25 04:57:43 +02:00
|
|
|
);
|
|
|
|
|
2011-10-03 18:30:07 +02:00
|
|
|
if ( wp_is_large_network( 'users' ) )
|
|
|
|
$args['search'] = ltrim( $args['search'], '*' );
|
2010-12-31 00:38:21 +01:00
|
|
|
|
2010-11-10 18:05:20 +01:00
|
|
|
if ( $role == 'super' ) {
|
|
|
|
$logins = implode( "', '", get_super_admins() );
|
|
|
|
$args['include'] = $wpdb->get_col( "SELECT ID FROM $wpdb->users WHERE user_login IN ('$logins')" );
|
|
|
|
}
|
|
|
|
|
2014-07-17 11:14:16 +02: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.
|
|
|
|
*/
|
2011-10-03 18:30:07 +02:00
|
|
|
if ( !$usersearch && wp_is_large_network( 'users' ) ) {
|
2010-11-03 14:34:04 +01:00
|
|
|
if ( !isset($_REQUEST['orderby']) )
|
|
|
|
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
|
|
|
|
if ( !isset($_REQUEST['order']) )
|
|
|
|
$_GET['order'] = $_REQUEST['order'] = 'DESC';
|
|
|
|
$args['count_total'] = false;
|
|
|
|
}
|
|
|
|
|
2010-10-25 04:57:43 +02:00
|
|
|
if ( isset( $_REQUEST['orderby'] ) )
|
|
|
|
$args['orderby'] = $_REQUEST['orderby'];
|
|
|
|
|
|
|
|
if ( isset( $_REQUEST['order'] ) )
|
|
|
|
$args['order'] = $_REQUEST['order'];
|
|
|
|
|
2010-11-28 18:39:44 +01:00
|
|
|
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
|
|
|
|
|
2010-10-25 04:57:43 +02:00
|
|
|
// Query the user IDs for this page
|
|
|
|
$wp_user_search = new WP_User_Query( $args );
|
|
|
|
|
|
|
|
$this->items = $wp_user_search->get_results();
|
|
|
|
|
|
|
|
$this->set_pagination_args( array(
|
|
|
|
'total_items' => $wp_user_search->get_total(),
|
|
|
|
'per_page' => $users_per_page,
|
|
|
|
) );
|
|
|
|
}
|
|
|
|
|
2015-05-29 22:17:26 +02: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-19 03:17:15 +02:00
|
|
|
protected function get_bulk_actions() {
|
2010-10-25 04:57:43 +02:00
|
|
|
$actions = array();
|
2010-11-12 17:00:41 +01:00
|
|
|
if ( current_user_can( 'delete_users' ) )
|
|
|
|
$actions['delete'] = __( 'Delete' );
|
2010-10-25 04:57:43 +02:00
|
|
|
$actions['spam'] = _x( 'Mark as Spam', 'user' );
|
|
|
|
$actions['notspam'] = _x( 'Not Spam', 'user' );
|
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2015-05-29 23:32:24 +02:00
|
|
|
/**
|
|
|
|
* @access public
|
|
|
|
*/
|
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-19 03:17:15 +02:00
|
|
|
public function no_items() {
|
2010-10-25 04:57:43 +02:00
|
|
|
_e( 'No users found.' );
|
|
|
|
}
|
|
|
|
|
2015-05-28 23:41:30 +02: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-19 03:17:15 +02:00
|
|
|
protected function get_views() {
|
2014-05-06 17:30:14 +02:00
|
|
|
global $role;
|
2010-11-10 18:05:20 +01:00
|
|
|
|
2010-11-24 21:03:28 +01:00
|
|
|
$total_users = get_user_count();
|
2010-11-10 18:05:20 +01:00
|
|
|
$super_admins = get_super_admins();
|
|
|
|
$total_admins = count( $super_admins );
|
|
|
|
|
|
|
|
$class = $role != 'super' ? ' class="current"' : '';
|
|
|
|
$role_links = array();
|
|
|
|
$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>';
|
|
|
|
$class = $role == 'super' ? ' class="current"' : '';
|
|
|
|
$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>';
|
|
|
|
|
|
|
|
return $role_links;
|
|
|
|
}
|
|
|
|
|
2014-12-01 01:33:23 +01:00
|
|
|
/**
|
|
|
|
* @global string $mode
|
|
|
|
* @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-19 03:17:15 +02:00
|
|
|
protected function pagination( $which ) {
|
2010-10-25 04:57:43 +02:00
|
|
|
global $mode;
|
|
|
|
|
|
|
|
parent::pagination ( $which );
|
|
|
|
|
|
|
|
if ( 'top' == $which )
|
|
|
|
$this->view_switcher( $mode );
|
|
|
|
}
|
|
|
|
|
2015-05-29 22:17:26 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2014-07-12 05:27:14 +02:00
|
|
|
public function get_columns() {
|
2010-10-25 04:57:43 +02:00
|
|
|
$users_columns = array(
|
|
|
|
'cb' => '<input type="checkbox" />',
|
2010-11-28 18:39:44 +01:00
|
|
|
'username' => __( 'Username' ),
|
2010-10-25 04:57:43 +02:00
|
|
|
'name' => __( 'Name' ),
|
|
|
|
'email' => __( 'E-mail' ),
|
|
|
|
'registered' => _x( 'Registered', 'user' ),
|
|
|
|
'blogs' => __( 'Sites' )
|
|
|
|
);
|
2013-11-23 23:25:10 +01:00
|
|
|
/**
|
|
|
|
* Filter the columns displayed in the Network Admin Users list table.
|
|
|
|
*
|
|
|
|
* @since MU
|
|
|
|
*
|
|
|
|
* @param array $users_columns An array of user columns. Default 'cb', 'username',
|
|
|
|
* 'name', 'email', 'registered', 'blogs'.
|
|
|
|
*/
|
2015-05-29 22:17:26 +02:00
|
|
|
return apply_filters( 'wpmu_users_columns', $users_columns );
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|
|
|
|
|
2015-05-29 22:17:26 +02: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-19 03:17:15 +02:00
|
|
|
protected function get_sortable_columns() {
|
2010-10-25 04:57:43 +02:00
|
|
|
return array(
|
2010-11-28 18:39:44 +01:00
|
|
|
'username' => 'login',
|
2010-10-25 04:57:43 +02:00
|
|
|
'name' => 'name',
|
|
|
|
'email' => 'email',
|
2010-11-11 12:47:10 +01:00
|
|
|
'registered' => 'id',
|
2010-10-25 04:57:43 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-28 23:41:30 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @global string $mode
|
|
|
|
*/
|
2014-07-14 00:09:16 +02:00
|
|
|
public function display_rows() {
|
2013-11-13 04:23:10 +01:00
|
|
|
global $mode;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
|
|
|
$super_admins = get_super_admins();
|
|
|
|
foreach ( $this->items as $user ) {
|
2015-01-14 23:14:22 +01:00
|
|
|
$class = '';
|
2010-10-25 04:57:43 +02:00
|
|
|
|
|
|
|
$status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
|
|
|
|
|
|
|
|
foreach ( $status_list as $status => $col ) {
|
|
|
|
if ( $user->$status )
|
2015-01-14 23:14:22 +01:00
|
|
|
$class .= " $col";
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
2015-01-14 23:14:22 +01:00
|
|
|
<tr class="<?php echo trim( $class ); ?>">
|
2010-10-25 04:57:43 +02:00
|
|
|
<?php
|
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
|
2010-10-25 04:57:43 +02:00
|
|
|
|
|
|
|
foreach ( $columns as $column_name => $column_display_name ) :
|
2015-05-29 04:41:25 +02:00
|
|
|
$classes = "$column_name column-$column_name";
|
|
|
|
if ( $primary === $column_name || 'blogs' === $column_name ) {
|
|
|
|
$classes .= ' has-row-actions';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $primary === $column_name ) {
|
|
|
|
$classes .= ' column-primary';
|
|
|
|
}
|
2010-11-28 18:39:44 +01:00
|
|
|
|
2010-11-13 21:47:34 +01:00
|
|
|
$style = '';
|
2015-05-29 04:41:25 +02:00
|
|
|
if ( in_array( $column_name, $hidden ) ) {
|
2010-11-13 21:47:34 +01:00
|
|
|
$style = ' style="display:none;"';
|
2015-05-29 04:41:25 +02:00
|
|
|
}
|
2010-11-13 21:47:34 +01:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
$attributes = "class='$classes'$style";
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
if ( 'cb' === $column_name ){
|
|
|
|
?>
|
|
|
|
<th scope="row" class="check-column">
|
|
|
|
<label class="screen-reader-text" for="blog_<?php echo $user->ID; ?>"><?php echo sprintf( __( 'Select %s' ), $user->user_login ); ?></label>
|
|
|
|
<input type="checkbox" id="blog_<?php echo $user->ID ?>" name="allusers[]" value="<?php echo esc_attr( $user->ID ) ?>" />
|
|
|
|
</th>
|
2010-10-25 04:57:43 +02:00
|
|
|
<?php
|
2015-05-29 04:41:25 +02:00
|
|
|
} else {
|
|
|
|
echo "<td $attributes>";
|
2015-05-29 22:17:26 +02:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
switch ( $column_name ) {
|
|
|
|
case 'username':
|
|
|
|
$avatar = get_avatar( $user->user_email, 32 );
|
|
|
|
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
|
|
|
|
|
|
|
echo $avatar; ?><strong><a href="<?php echo $edit_link; ?>" class="edit"><?php echo $user->user_login; ?></a><?php
|
2010-10-25 04:57:43 +02:00
|
|
|
if ( in_array( $user->user_login, $super_admins ) )
|
2010-11-10 18:05:20 +01:00
|
|
|
echo ' - ' . __( 'Super Admin' );
|
2010-10-25 04:57:43 +02:00
|
|
|
?></strong>
|
2015-05-29 04:41:25 +02:00
|
|
|
<?php
|
|
|
|
break;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
case 'name':
|
|
|
|
echo "$user->first_name $user->last_name";
|
|
|
|
break;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
case 'email':
|
|
|
|
echo "<a href='mailto:$user->user_email'>$user->user_email</a>";
|
|
|
|
break;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
case 'registered':
|
|
|
|
if ( 'list' == $mode )
|
|
|
|
$date = __( 'Y/m/d' );
|
|
|
|
else
|
|
|
|
$date = __( 'Y/m/d g:i:s a' );
|
2010-11-28 18:39:44 +01:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
echo mysql2date( $date, $user->user_registered );
|
|
|
|
break;
|
2010-10-25 04:57:43 +02:00
|
|
|
|
2015-05-29 04:41:25 +02:00
|
|
|
case 'blogs':
|
|
|
|
$blogs = get_blogs_of_user( $user->ID, true );
|
2010-10-25 04:57:43 +02:00
|
|
|
if ( is_array( $blogs ) ) {
|
|
|
|
foreach ( (array) $blogs as $key => $val ) {
|
2010-12-09 13:36:39 +01:00
|
|
|
if ( !can_edit_network( $val->site_id ) )
|
2010-12-07 15:28:40 +01:00
|
|
|
continue;
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2010-12-07 15:28:40 +01:00
|
|
|
$path = ( $val->path == '/' ) ? '' : $val->path;
|
2010-12-07 16:00:30 +01:00
|
|
|
echo '<span class="site-' . $val->site_id . '" >';
|
2013-11-13 04:23:10 +01:00
|
|
|
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>';
|
2010-12-07 16:00:30 +01:00
|
|
|
echo ' <small class="row-actions">';
|
2010-11-29 14:31:42 +01:00
|
|
|
$actions = array();
|
|
|
|
$actions['edit'] = '<a href="'. esc_url( network_admin_url( 'site-info.php?id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a>';
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2010-11-29 14:31:42 +01:00
|
|
|
$class = '';
|
2015-05-28 01:14:29 +02:00
|
|
|
if ( $val->spam == 1 ) {
|
2010-11-29 14:31:42 +01:00
|
|
|
$class .= 'site-spammed ';
|
2015-05-28 01:14:29 +02:00
|
|
|
}
|
|
|
|
if ( $val->mature == 1 ) {
|
2010-11-29 14:31:42 +01:00
|
|
|
$class .= 'site-mature ';
|
2015-05-28 01:14:29 +02:00
|
|
|
}
|
|
|
|
if ( $val->deleted == 1 ) {
|
2010-11-29 14:31:42 +01:00
|
|
|
$class .= 'site-deleted ';
|
2015-05-28 01:14:29 +02:00
|
|
|
}
|
|
|
|
if ( $val->archived == 1 ) {
|
2010-11-29 14:31:42 +01:00
|
|
|
$class .= 'site-archived ';
|
2015-05-28 01:14:29 +02:00
|
|
|
}
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2011-12-14 00:45:31 +01:00
|
|
|
$actions['view'] = '<a class="' . $class . '" href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2013-11-23 23:25:10 +01:00
|
|
|
/**
|
|
|
|
* Filter the action links displayed next the sites a user belongs to
|
|
|
|
* in the Network Admin Users list table.
|
|
|
|
*
|
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @param array $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, $val->userblog_id );
|
2010-12-13 22:21:50 +01:00
|
|
|
|
2010-11-29 14:31:42 +01:00
|
|
|
$i=0;
|
|
|
|
$action_count = count( $actions );
|
|
|
|
foreach ( $actions as $action => $link ) {
|
|
|
|
++$i;
|
|
|
|
( $i == $action_count ) ? $sep = '' : $sep = ' | ';
|
|
|
|
echo "<span class='$action'>$link$sep</span>";
|
|
|
|
}
|
2010-12-15 19:34:59 +01:00
|
|
|
echo '</small></span><br/>';
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|
|
|
|
}
|
2015-05-29 04:41:25 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/** 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 );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $this->handle_row_actions( $user, $column_name, $primary );
|
|
|
|
echo '</td>';
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|
|
|
|
endforeach
|
|
|
|
?>
|
|
|
|
</tr>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
}
|
2015-05-29 04:41:25 +02:00
|
|
|
|
|
|
|
/**
|
2015-05-31 03:38:26 +02:00
|
|
|
* Get the name of the default primary column.
|
2015-05-29 04:41:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
|
|
|
* @access protected
|
|
|
|
*
|
2015-05-31 03:38:26 +02:00
|
|
|
* @return string Name of the default primary column, in this case, 'username'.
|
2015-05-29 04:41:25 +02:00
|
|
|
*/
|
|
|
|
protected function get_default_primary_column_name() {
|
|
|
|
return 'username';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-31 03:38:26 +02:00
|
|
|
* Generate and display row actions links.
|
2015-05-29 04:41:25 +02:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
|
|
|
* @access protected
|
|
|
|
*
|
2015-05-31 03:38:26 +02:00
|
|
|
* @param object $user 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.
|
2015-05-29 04:41:25 +02:00
|
|
|
*/
|
|
|
|
protected function handle_row_actions( $user, $column_name, $primary ) {
|
|
|
|
$super_admins = get_super_admins();
|
|
|
|
$edit_link = esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), get_edit_user_link( $user->ID ) ) );
|
|
|
|
|
|
|
|
if ( $primary === $column_name ) {
|
|
|
|
$actions = array();
|
|
|
|
$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
|
|
|
|
|
|
|
|
if ( current_user_can( 'delete_user', $user->ID ) && ! in_array( $user->user_login, $super_admins ) ) {
|
|
|
|
$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' ) . '&action=deleteuser&id=' . $user->ID ) ) ) . '" class="delete">' . __( 'Delete' ) . '</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-05-31 03:38:26 +02:00
|
|
|
* Filter the action links displayed under each user in the Network Admin Users list table.
|
2015-05-29 04:41:25 +02:00
|
|
|
*
|
|
|
|
* @since 3.2.0
|
|
|
|
*
|
|
|
|
* @param array $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 );
|
|
|
|
return $this->row_actions( $actions );
|
|
|
|
}
|
|
|
|
}
|
2010-10-25 04:57:43 +02:00
|
|
|
}
|