diff -r c7c34916027a -r 177826044cd9 wp/wp-admin/includes/class-wp-ms-sites-list-table.php
--- a/wp/wp-admin/includes/class-wp-ms-sites-list-table.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/includes/class-wp-ms-sites-list-table.php Mon Oct 14 18:28:13 2019 +0200
@@ -39,17 +39,18 @@
'archived' => array( 'site-archived', __( 'Archived' ) ),
'spam' => array( 'site-spammed', _x( 'Spam', 'site' ) ),
'deleted' => array( 'site-deleted', __( 'Deleted' ) ),
- 'mature' => array( 'site-mature', __( 'Mature' ) )
+ 'mature' => array( 'site-mature', __( 'Mature' ) ),
);
- parent::__construct( array(
- 'plural' => 'sites',
- 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
- ) );
+ parent::__construct(
+ array(
+ 'plural' => 'sites',
+ 'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
+ )
+ );
}
/**
- *
* @return bool
*/
public function ajax_user_can() {
@@ -79,22 +80,24 @@
$pagenum = $this->get_pagenum();
- $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST[ 's' ] ) ) : '';
+ $s = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
$wild = '';
- if ( false !== strpos($s, '*') ) {
+ if ( false !== strpos( $s, '*' ) ) {
$wild = '*';
- $s = trim($s, '*');
+ $s = trim( $s, '*' );
}
/*
* If the network is large and a search is not being performed, show only
* the latest sites with no paging in order to avoid expensive count queries.
*/
- if ( !$s && wp_is_large_network() ) {
- if ( !isset($_REQUEST['orderby']) )
+ if ( ! $s && wp_is_large_network() ) {
+ if ( ! isset( $_REQUEST['orderby'] ) ) {
$_GET['orderby'] = $_REQUEST['orderby'] = '';
- if ( !isset($_REQUEST['order']) )
+ }
+ if ( ! isset( $_REQUEST['order'] ) ) {
$_GET['order'] = $_REQUEST['order'] = 'DESC';
+ }
}
$args = array(
@@ -103,14 +106,14 @@
'network_id' => get_current_network_id(),
);
- if ( empty($s) ) {
+ if ( empty( $s ) ) {
// Nothing to do.
} elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||
preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {
// IPv4 address
- $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
+ $sql = $wpdb->prepare( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE %s", $wpdb->esc_like( $s ) . ( ! empty( $wild ) ? '%' : '' ) );
$reg_blog_ids = $wpdb->get_col( $sql );
if ( $reg_blog_ids ) {
@@ -146,7 +149,7 @@
$args['orderby'] = $order_by;
if ( $order_by ) {
- $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? "DESC" : "ASC";
+ $args['order'] = ( isset( $_REQUEST['order'] ) && 'DESC' === strtoupper( $_REQUEST['order'] ) ) ? 'DESC' : 'ASC';
}
if ( wp_is_large_network() ) {
@@ -171,16 +174,23 @@
$this->items = array_slice( $_sites, 0, $per_page );
}
- $total_sites = get_sites( array_merge( $args, array(
- 'count' => true,
- 'offset' => 0,
- 'number' => 0,
- ) ) );
+ $total_sites = get_sites(
+ array_merge(
+ $args,
+ array(
+ 'count' => true,
+ 'offset' => 0,
+ 'number' => 0,
+ )
+ )
+ );
- $this->set_pagination_args( array(
- 'total_items' => $total_sites,
- 'per_page' => $per_page,
- ) );
+ $this->set_pagination_args(
+ array(
+ 'total_items' => $total_sites,
+ 'per_page' => $per_page,
+ )
+ );
}
/**
@@ -190,14 +200,14 @@
}
/**
- *
* @return array
*/
protected function get_bulk_actions() {
$actions = array();
- if ( current_user_can( 'delete_sites' ) )
+ if ( current_user_can( 'delete_sites' ) ) {
$actions['delete'] = __( 'Delete' );
- $actions['spam'] = _x( 'Mark as Spam', 'site' );
+ }
+ $actions['spam'] = _x( 'Mark as Spam', 'site' );
$actions['notspam'] = _x( 'Not Spam', 'site' );
return $actions;
@@ -213,8 +223,9 @@
parent::pagination( $which );
- if ( 'top' === $which )
+ if ( 'top' === $which ) {
$this->view_switcher( $mode );
+ }
}
/**
@@ -238,8 +249,8 @@
*
* @since MU (3.0.0)
*
- * @param array $sites_columns An array of displayed site columns. Default 'cb',
- * 'blogname', 'lastupdated', 'registered', 'users'.
+ * @param string[] $sites_columns An array of displayed site columns. Default 'cb',
+ * 'blogname', 'lastupdated', 'registered', 'users'.
*/
return apply_filters( 'wpmu_blogs_columns', $sites_columns );
}
@@ -265,12 +276,15 @@
public function column_cb( $blog ) {
if ( ! is_main_site( $blog['blog_id'] ) ) :
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
- ?>
-
-
-
+
+
+ status_list );
@@ -308,11 +322,11 @@
$blog_state = '';
if ( ! empty( $blog_states ) ) {
$state_count = count( $blog_states );
- $i = 0;
+ $i = 0;
$blog_state .= ' — ';
foreach ( $blog_states as $state ) {
++$i;
- $sep = ( $i == $state_count ) ? '' : ', ';
+ $sep = ( $i == $state_count ) ? '' : ', ';
$blog_state .= "$state$sep";
}
}
@@ -393,9 +407,15 @@
public function column_users( $blog ) {
$user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
if ( ! $user_count ) {
- $blog_users = get_users( array( 'blog_id' => $blog['blog_id'], 'fields' => 'ID' ) );
- $user_count = count( $blog_users );
- unset( $blog_users );
+ $blog_users = new WP_User_Query(
+ array(
+ 'blog_id' => $blog['blog_id'],
+ 'fields' => 'ID',
+ 'number' => 1,
+ 'count_total' => true,
+ )
+ );
+ $user_count = $blog_users->get_total();
wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
}
@@ -449,12 +469,11 @@
}
/**
- *
* @global string $mode
*/
public function display_rows() {
foreach ( $this->items as $blog ) {
- $blog = $blog->to_array();
+ $blog = $blog->to_array();
$class = '';
reset( $this->status_list );
@@ -502,19 +521,23 @@
// Preordered.
$actions = array(
- 'edit' => '', 'backend' => '',
- 'activate' => '', 'deactivate' => '',
- 'archive' => '', 'unarchive' => '',
- 'spam' => '', 'unspam' => '',
- 'delete' => '',
- 'visit' => '',
+ 'edit' => '',
+ 'backend' => '',
+ 'activate' => '',
+ 'deactivate' => '',
+ 'archive' => '',
+ 'unarchive' => '',
+ 'spam' => '',
+ 'unspam' => '',
+ 'delete' => '',
+ 'visit' => '',
);
- $actions['edit'] = '' . __( 'Edit' ) . '';
- $actions['backend'] = "" . __( 'Dashboard' ) . '';
+ $actions['edit'] = '' . __( 'Edit' ) . '';
+ $actions['backend'] = "" . __( 'Dashboard' ) . '';
if ( get_network()->site_id != $blog['blog_id'] ) {
if ( $blog['deleted'] == '1' ) {
- $actions['activate'] = '' . __( 'Activate' ) . '';
+ $actions['activate'] = '' . __( 'Activate' ) . '';
} else {
$actions['deactivate'] = '' . __( 'Deactivate' ) . '';
}
@@ -522,13 +545,13 @@
if ( $blog['archived'] == '1' ) {
$actions['unarchive'] = '' . __( 'Unarchive' ) . '';
} else {
- $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . '';
+ $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . '';
}
if ( $blog['spam'] == '1' ) {
$actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . '';
} else {
- $actions['spam'] = '' . _x( 'Spam', 'site' ) . '';
+ $actions['spam'] = '' . _x( 'Spam', 'site' ) . '';
}
if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) {
@@ -536,7 +559,7 @@
}
}
- $actions['visit'] = "" . __( 'Visit' ) . '';
+ $actions['visit'] = "" . __( 'Visit' ) . '';
/**
* Filters the action links displayed for each site in the Sites list table.
@@ -548,10 +571,10 @@
*
* @since 3.1.0
*
- * @param array $actions An array of action links to be displayed.
- * @param int $blog_id The site ID.
- * @param string $blogname Site path, formatted depending on whether it is a sub-domain
- * or subdirectory multisite installation.
+ * @param string[] $actions An array of action links to be displayed.
+ * @param int $blog_id The site ID.
+ * @param string $blogname Site path, formatted depending on whether it is a sub-domain
+ * or subdirectory multisite installation.
*/
$actions = apply_filters( 'manage_sites_action_links', array_filter( $actions ), $blog['blog_id'], $blogname );
return $this->row_actions( $actions );