From 87234faca2f4c0cda31d3e1c933cd642e65fdc4d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 22 Aug 2007 18:03:26 +0000 Subject: [PATCH] posts_results and posts_selection hooks. fixes #4799 git-svn-id: https://develop.svn.wordpress.org/trunk@5916 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index f91412769a..bbda607ff6 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1128,13 +1128,19 @@ class WP_Query { } // Apply post-paging filters on where and join. Only plugins that - // manipulate paging queries should use these hooks. + // manipulate paging queries should use these hooks. + + // Announce current selection parameters. For use by caching plugins. + do_action( 'posts_selection', $where . $groupby . $q['orderby'] . $limits . $join ); + $where = apply_filters('posts_where_paged', $where); $groupby = apply_filters('posts_groupby', $groupby); if ( ! empty($groupby) ) $groupby = 'GROUP BY ' . $groupby; $join = apply_filters('posts_join_paged', $join); $orderby = apply_filters('posts_orderby', $q['orderby']); + if ( !empty( $orderby ) ) + $orderby = 'ORDER BY ' . $orderby; $distinct = apply_filters('posts_distinct', $distinct); $fields = apply_filters('posts_fields', "$wpdb->posts.*"); $limits = apply_filters( 'post_limits', $limits ); @@ -1142,10 +1148,12 @@ class WP_Query { if ( !empty($limits) ) $found_rows = 'SQL_CALC_FOUND_ROWS'; - $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits"; + $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; $this->request = apply_filters('posts_request', $request); $this->posts = $wpdb->get_results($this->request); + // Raw results filter. Prior to status checks. + $this->posts = apply_filters('posts_results', $this->posts); if ( $this->is_comment_feed && $this->is_singular ) { $cjoin = apply_filters('comment_feed_join', '');