From c2ab97264d5f0c178776d1b6dc6d4d97cb21b7c5 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 24 Sep 2018 22:53:12 +0000 Subject: [PATCH] Users: Pass the current `WP_User_Query` instance to `found_users_query` filter. Props spacedmonkey. Fixes #43679. git-svn-id: https://develop.svn.wordpress.org/trunk@43660 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp-user-query.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/class-wp-user-query.php b/src/wp-includes/class-wp-user-query.php index 575eab90c9..1218c87c8b 100644 --- a/src/wp-includes/class-wp-user-query.php +++ b/src/wp-includes/class-wp-user-query.php @@ -600,17 +600,21 @@ class WP_User_Query { $this->results = $wpdb->get_col( $this->request ); } - /** - * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance. - * - * @since 3.2.0 - * - * @global wpdb $wpdb WordPress database abstraction object. - * - * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query. - */ if ( isset( $qv['count_total'] ) && $qv['count_total'] ) { - $this->total_users = (int) $wpdb->get_var( apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()' ) ); + /** + * Filters SELECT FOUND_ROWS() query for the current WP_User_Query instance. + * + * @since 3.2.0 + * @since 4.9.9 Added the `$this` parameter. + * + * @global wpdb $wpdb WordPress database abstraction object. + * + * @param string $sql The SELECT FOUND_ROWS() query for the current WP_User_Query. + * @param WP_User_Query $this The current WP_User_Query instance. + */ + $found_users_query = apply_filters( 'found_users_query', 'SELECT FOUND_ROWS()', $this ); + + $this->total_users = (int) $wpdb->get_var( $found_users_query ); } if ( ! $this->results ) {