From 0f3835d39463e12e579029683d3f9ddeb0f9c2c4 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Tue, 8 Jan 2019 09:49:50 +0000 Subject: [PATCH] Users: Add the `pre_count_users` filter. Props spacedmonkey. Fixes #43693. Built from https://develop.svn.wordpress.org/trunk@44473 git-svn-id: http://core.svn.wordpress.org/trunk@44304 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 18 ++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 0febf4aa37..9f0a917b17 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -882,6 +882,24 @@ function count_users( $strategy = 'time', $site_id = null ) { if ( ! $site_id ) { $site_id = get_current_blog_id(); } + + /** + * Filter the user count before queries are run. Return a non-null value to cause count_users() + * to return early. + * + * @since 5.1.0 + * + * @param null|string $result Default null. + * @param string $strategy Optional. The computational strategy to use when counting the users. + * Accepts either 'time' or 'memory'. Default 'time'. + * @param int|null $site_id Optional. The site ID to count users for. Defaults to the current site. + */ + $pre = apply_filters( 'pre_count_users', null, $strategy, $site_id ); + + if ( null !== $pre ) { + return $pre; + } + $blog_prefix = $wpdb->get_blog_prefix( $site_id ); $result = array(); diff --git a/wp-includes/version.php b/wp-includes/version.php index 4674d7cce5..45ae42defa 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-alpha-44472'; +$wp_version = '5.1-alpha-44473'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.