mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 14:47:02 +00:00
Users: Introduce the concept of a large site in order to speed up the Users screen when there are many users.
Calling the `count_users()` function is expensive, regardless of the counting strategy that's used, and it gets slower the more users there are on a site. In order to speed up the Users screen in the admin area, calling `count_users()` can be avoided entirely while still displaying the total count for users. This introduces some new functions: * `wp_is_large_user_count()` * `wp_get_active_user_count()` * `wp_update_active_user_count()` A corresponding `wp_is_large_user_count` filter is also introduced. Props tharsheblows, johnbillion Fixes #38741 git-svn-id: https://develop.svn.wordpress.org/trunk@41613 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2553,6 +2553,11 @@ function wp_is_large_network( $using = 'sites', $network_id = null ) {
|
||||
|
||||
if ( 'users' == $using ) {
|
||||
$count = get_user_count( $network_id );
|
||||
$is_large = ( $count > 10000 );
|
||||
|
||||
/** This filter is documented in wp-includes/functions.php */
|
||||
$is_large = apply_filters( 'wp_is_large_user_count', $is_large, $count );
|
||||
|
||||
/**
|
||||
* Filters whether the network is considered large.
|
||||
*
|
||||
@@ -2564,7 +2569,7 @@ function wp_is_large_network( $using = 'sites', $network_id = null ) {
|
||||
* @param int $count The count of items for the component.
|
||||
* @param int $network_id The ID of the network being checked.
|
||||
*/
|
||||
return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
|
||||
return apply_filters( 'wp_is_large_network', $is_large, 'users', $count, $network_id );
|
||||
}
|
||||
|
||||
$count = get_blog_count( $network_id );
|
||||
|
||||
Reference in New Issue
Block a user