Consolidate larg network criteria into wp_is_large_network(). Allow plugins to change this criteria via filter. Props PeteMall. fixes #18464
git-svn-id: http://svn.automattic.com/wordpress/trunk@18871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
40794ebcd5
commit
69994de5d1
|
@ -37,15 +37,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
$like_s = esc_sql( like_escape( $s ) );
|
$like_s = esc_sql( like_escape( $s ) );
|
||||||
|
|
||||||
$large_network = false;
|
|
||||||
// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
|
// If the network is large and a search is not being performed, show only the latest blogs with no paging in order
|
||||||
// to avoid expensive count queries.
|
// to avoid expensive count queries.
|
||||||
if ( !$s && ( get_blog_count() >= 10000 ) ) {
|
if ( !$s && wp_is_large_network() ) {
|
||||||
if ( !isset($_REQUEST['orderby']) )
|
if ( !isset($_REQUEST['orderby']) )
|
||||||
$_GET['orderby'] = $_REQUEST['orderby'] = '';
|
$_GET['orderby'] = $_REQUEST['orderby'] = '';
|
||||||
if ( !isset($_REQUEST['order']) )
|
if ( !isset($_REQUEST['order']) )
|
||||||
$_GET['order'] = $_REQUEST['order'] = 'DESC';
|
$_GET['order'] = $_REQUEST['order'] = 'DESC';
|
||||||
$large_network = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
|
$query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
|
||||||
|
@ -104,13 +102,13 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't do an unbounded count on large networks
|
// Don't do an unbounded count on large networks
|
||||||
if ( ! $large_network )
|
if ( ! wp_is_large_network() )
|
||||||
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
|
$total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT( blog_id )', $query ) );
|
||||||
|
|
||||||
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
|
$query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page ) . ", " . intval( $per_page );
|
||||||
$this->items = $wpdb->get_results( $query, ARRAY_A );
|
$this->items = $wpdb->get_results( $query, ARRAY_A );
|
||||||
|
|
||||||
if ( $large_network )
|
if ( wp_is_large_network() )
|
||||||
$total = count($this->items);
|
$total = count($this->items);
|
||||||
|
|
||||||
$this->set_pagination_args( array(
|
$this->set_pagination_args( array(
|
||||||
|
|
|
@ -32,7 +32,8 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||||
'fields' => 'all_with_meta'
|
'fields' => 'all_with_meta'
|
||||||
);
|
);
|
||||||
|
|
||||||
$args['search'] = ltrim($args['search'], '*');
|
if ( wp_is_large_network( 'users' ) )
|
||||||
|
$args['search'] = ltrim( $args['search'], '*' );
|
||||||
|
|
||||||
if ( $role == 'super' ) {
|
if ( $role == 'super' ) {
|
||||||
$logins = implode( "', '", get_super_admins() );
|
$logins = implode( "', '", get_super_admins() );
|
||||||
|
@ -41,7 +42,7 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
||||||
|
|
||||||
// If the network is large and a search is not being performed, show only the latest users with no paging in order
|
// 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.
|
// to avoid expensive count queries.
|
||||||
if ( !$usersearch && ( get_blog_count() >= 10000 ) ) {
|
if ( !$usersearch && wp_is_large_network( 'users' ) ) {
|
||||||
if ( !isset($_REQUEST['orderby']) )
|
if ( !isset($_REQUEST['orderby']) )
|
||||||
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
|
$_GET['orderby'] = $_REQUEST['orderby'] = 'id';
|
||||||
if ( !isset($_REQUEST['order']) )
|
if ( !isset($_REQUEST['order']) )
|
||||||
|
|
|
@ -775,4 +775,23 @@ var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png";
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether or not we have a large network.
|
||||||
|
*
|
||||||
|
* The default criteria for a large network is either more than 10,000 users or more than 10,000 sites.
|
||||||
|
* Plugins can alter this criteria using the 'wp_is_large_network' filter.
|
||||||
|
*
|
||||||
|
* @since 3.3.0
|
||||||
|
* @param string $using 'sites or 'users'. Default is 'sites'.
|
||||||
|
* @return bool True if the network meets the criteria for large. False otherwise.
|
||||||
|
*/
|
||||||
|
function wp_is_large_network( $using = 'sites' ) {
|
||||||
|
if ( 'users' == $using ) {
|
||||||
|
$count = get_user_count();
|
||||||
|
return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count );
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = get_blog_count();
|
||||||
|
return apply_filters( 'wp_is_large_network', $count > 10000, 'sites', $count );
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue