From 53d8aaf3fc1e2e82bd82f08832e2d00d9f71fe95 Mon Sep 17 00:00:00 2001 From: scribu Date: Mon, 11 Oct 2010 15:04:44 +0000 Subject: [PATCH] Introduce wp_query_clauses filter. Fixes #14997 git-svn-id: https://develop.svn.wordpress.org/trunk@15775 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 17b8fe9411..9f6c874ff0 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2186,13 +2186,25 @@ class WP_Query extends WP_Object_Query { // Apply post-paging filters on where and join. Only plugins that // manipulate paging queries should use these hooks. if ( !$q['suppress_filters'] ) { - $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); - $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); - $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); - $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); $distinct = apply_filters_ref_array( 'posts_distinct', array( $distinct, &$this ) ); - $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); $fields = apply_filters_ref_array( 'posts_fields', array( $fields, &$this ) ); + $where = apply_filters_ref_array( 'posts_where_paged', array( $where, &$this ) ); + $join = apply_filters_ref_array( 'posts_join_paged', array( $join, &$this ) ); + $groupby = apply_filters_ref_array( 'posts_groupby', array( $groupby, &$this ) ); + $orderby = apply_filters_ref_array( 'posts_orderby', array( $orderby, &$this ) ); + $limits = apply_filters_ref_array( 'post_limits', array( $limits, &$this ) ); + + // Also apply a filter on all clauses at once, for convenience + $clauses = array(); + foreach ( array('distinct', 'fields', 'where', 'join', 'groupby', 'orderby', 'limits') as $var ) { + $clauses[ $var ] = $$var; + unset( $$var ); // so we can use EXTR_SKIP below + } + + $clauses = apply_filters_ref_array( 'wp_query_clauses', array( $clauses, &$this ) ); + + extract( $clauses, EXTR_SKIP ); + unset( $clauses ); } // Announce current selection parameters. For use by caching plugins. @@ -2200,13 +2212,13 @@ class WP_Query extends WP_Object_Query { // Filter again for the benefit of caching plugins. Regular plugins should use the hooks above. if ( !$q['suppress_filters'] ) { + $distinct = apply_filters_ref_array( 'posts_distinct_request',array( $distinct, &$this ) ); + $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); $where = apply_filters_ref_array( 'posts_where_request', array( $where, &$this ) ); - $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); $join = apply_filters_ref_array( 'posts_join_request', array( $join, &$this ) ); - $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); - $distinct = apply_filters_ref_array( 'posts_distinct_request', array( $distinct, &$this ) ); - $fields = apply_filters_ref_array( 'posts_fields_request', array( $fields, &$this ) ); - $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); + $groupby = apply_filters_ref_array( 'posts_groupby_request', array( $groupby, &$this ) ); + $orderby = apply_filters_ref_array( 'posts_orderby_request', array( $orderby, &$this ) ); + $limits = apply_filters_ref_array( 'post_limits_request', array( $limits, &$this ) ); } if ( ! empty($groupby) )