WordPress.org

Make WordPress Core

Ticket #4799: query_hooks.diff

File query_hooks.diff, 1.7 KB (added by ryan, 11 years ago)
  • wp-includes/query.php

     
    11281128                }
    11291129
    11301130                // Apply post-paging filters on where and join.  Only plugins that
    1131                 // manipulate paging queries should use these hooks.
     1131                // manipulate paging queries should use these hooks.   
     1132
     1133                // Announce current selection parameters.  For use by caching plugins.
     1134                do_action( 'posts_selection', $where . $groupby . $q['orderby'] . $limits . $join );
     1135
    11321136                $where = apply_filters('posts_where_paged', $where);
    11331137                $groupby = apply_filters('posts_groupby', $groupby);
    11341138                if ( ! empty($groupby) )
    11351139                        $groupby = 'GROUP BY ' . $groupby;
    11361140                $join = apply_filters('posts_join_paged', $join);
    11371141                $orderby = apply_filters('posts_orderby', $q['orderby']);
     1142                if ( !empty( $orderby ) )
     1143                        $orderby = 'ORDER BY ' . $orderby;
    11381144                $distinct = apply_filters('posts_distinct', $distinct);
    11391145                $fields = apply_filters('posts_fields', "$wpdb->posts.*");
    11401146                $limits = apply_filters( 'post_limits', $limits );
     
    11421148                if ( !empty($limits) )
    11431149                        $found_rows = 'SQL_CALC_FOUND_ROWS';
    11441150
    1145                 $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
     1151                $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
    11461152                $this->request = apply_filters('posts_request', $request);
    11471153
    11481154                $this->posts = $wpdb->get_results($this->request);
     1155                // Raw results filter.  Prior to status checks.
     1156                $this->posts = apply_filters('posts_results', $this->posts);
    11491157
    11501158                if ( $this->is_comment_feed && $this->is_singular ) {
    11511159                        $cjoin = apply_filters('comment_feed_join', '');