WordPress.org

Make WordPress Core

Ticket #9886: 9886.diff

File 9886.diff, 6.9 KB (added by scribu, 4 years ago)
  • wp-includes/query.php

     
    17651765                                        $search .= " AND ($wpdb->posts.post_password = '') "; 
    17661766                        } 
    17671767                } 
    1768                 $search = apply_filters('posts_search', $search, $this); 
     1768                $search = apply_filters('posts_search', $search, &$this); 
    17691769 
    17701770                // Category stuff 
    17711771 
     
    21962196                // Apply filters on where and join prior to paging so that any 
    21972197                // manipulations to them are reflected in the paging by day queries. 
    21982198                if ( !$q['suppress_filters'] ) { 
    2199                         $where = apply_filters('posts_where', $where); 
    2200                         $join = apply_filters('posts_join', $join); 
     2199                        $where = apply_filters('posts_where', $where, &$this); 
     2200                        $join = apply_filters('posts_join', $join, &$this); 
    22012201                } 
    22022202 
    22032203                // Paging 
     
    22312231                        } 
    22322232 
    22332233                        if ( !$q['suppress_filters'] ) { 
    2234                                 $cjoin = apply_filters('comment_feed_join', $cjoin); 
    2235                                 $cwhere = apply_filters('comment_feed_where', $cwhere); 
    2236                                 $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 
    2237                                 $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
    2238                                 $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2234                                $cjoin = apply_filters('comment_feed_join', $cjoin, &$this); 
     2235                                $cwhere = apply_filters('comment_feed_where', $cwhere, &$this); 
     2236                                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby, &$this); 
     2237                                $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', &$this); 
     2238                                $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), &$this); 
    22392239                        } 
    22402240                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
    22412241                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
     
    22612261                // Apply post-paging filters on where and join.  Only plugins that 
    22622262                // manipulate paging queries should use these hooks. 
    22632263                if ( !$q['suppress_filters'] ) { 
    2264                         $where = apply_filters('posts_where_paged', $where); 
    2265                         $groupby = apply_filters('posts_groupby', $groupby); 
    2266                         $join = apply_filters('posts_join_paged', $join); 
    2267                         $orderby = apply_filters('posts_orderby', $orderby); 
    2268                         $distinct = apply_filters('posts_distinct', $distinct); 
    2269                         $limits = apply_filters( 'post_limits', $limits ); 
    2270  
    2271                         $fields = apply_filters('posts_fields', $fields); 
     2264                        $where = apply_filters('posts_where_paged', $where, &$this); 
     2265                        $groupby = apply_filters('posts_groupby', $groupby, &$this); 
     2266                        $join = apply_filters('posts_join_paged', $join, &$this); 
     2267                        $orderby = apply_filters('posts_orderby', $orderby, &$this); 
     2268                        $distinct = apply_filters('posts_distinct', $distinct, &$this); 
     2269                        $limits = apply_filters('post_limits', $limits, &$this); 
     2270                        $fields = apply_filters('posts_fields', $fields, &$this); 
    22722271                } 
    22732272 
    22742273                // Announce current selection parameters.  For use by caching plugins. 
     
    22762275 
    22772276                // Filter again for the benefit of caching plugins.  Regular plugins should use the hooks above. 
    22782277                if ( !$q['suppress_filters'] ) { 
    2279                         $where = apply_filters('posts_where_request', $where); 
    2280                         $groupby = apply_filters('posts_groupby_request', $groupby); 
    2281                         $join = apply_filters('posts_join_request', $join); 
    2282                         $orderby = apply_filters('posts_orderby_request', $orderby); 
    2283                         $distinct = apply_filters('posts_distinct_request', $distinct); 
    2284                         $fields = apply_filters('posts_fields_request', $fields); 
    2285                         $limits = apply_filters( 'post_limits_request', $limits ); 
     2278                        $where = apply_filters('posts_where_request', $where, &$this); 
     2279                        $groupby = apply_filters('posts_groupby_request', $groupby, &$this); 
     2280                        $join = apply_filters('posts_join_request', $join, &$this); 
     2281                        $orderby = apply_filters('posts_orderby_request', $orderby, &$this); 
     2282                        $distinct = apply_filters('posts_distinct_request', $distinct, &$this); 
     2283                        $fields = apply_filters('posts_fields_request', $fields, &$this); 
     2284                        $limits = apply_filters('post_limits_request', $limits, &$this); 
    22862285                } 
    22872286 
    22882287                if ( ! empty($groupby) ) 
     
    22952294 
    22962295                $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits"; 
    22972296                if ( !$q['suppress_filters'] ) 
    2298                         $this->request = apply_filters('posts_request', $this->request); 
     2297                        $this->request = apply_filters('posts_request', $this->request, &$this); 
    22992298 
    23002299                $this->posts = $wpdb->get_results($this->request); 
    23012300                // Raw results filter.  Prior to status checks. 
    23022301                if ( !$q['suppress_filters'] ) 
    2303                         $this->posts = apply_filters('posts_results', $this->posts); 
     2302                        $this->posts = apply_filters('posts_results', $this->posts, &$this); 
    23042303 
    23052304                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    2306                         $cjoin = apply_filters('comment_feed_join', ''); 
    2307                         $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); 
    2308                         $cgroupby = apply_filters('comment_feed_groupby', ''); 
     2305                        $cjoin = apply_filters('comment_feed_join', '', &$this); 
     2306                        $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'", &$this); 
     2307                        $cgroupby = apply_filters('comment_feed_groupby', '', &$this); 
    23092308                        $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
    2310                         $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2309                        $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC', &$this); 
    23112310                        $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
    2312                         $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2311                        $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss'), &$this); 
    23132312                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 
    23142313                        $this->comments = $wpdb->get_results($comments_request); 
    23152314                        $this->comment_count = count($this->comments); 
    23162315                } 
    23172316 
    23182317                if ( !empty($limits) ) { 
    2319                         $found_posts_query = apply_filters( 'found_posts_query', 'SELECT FOUND_ROWS()' ); 
     2318                        $found_posts_query = apply_filters('found_posts_query', 'SELECT FOUND_ROWS()', &$this); 
    23202319                        $this->found_posts = $wpdb->get_var( $found_posts_query ); 
    2321                         $this->found_posts = apply_filters( 'found_posts', $this->found_posts ); 
     2320                        $this->found_posts = apply_filters('found_posts', $this->found_posts, &$this); 
    23222321                        $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']); 
    23232322                } 
    23242323 
     
    23512350                        } 
    23522351 
    23532352                        if ( $this->is_preview && current_user_can( $edit_cap, $this->posts[0]->ID ) ) 
    2354                                 $this->posts[0] = apply_filters('the_preview', $this->posts[0]); 
     2353                                $this->posts[0] = apply_filters('the_preview', $this->posts[0], &$this); 
    23552354                } 
    23562355 
    23572356                // Put sticky posts at the top of the posts array 
     
    24002399                } 
    24012400 
    24022401                if ( !$q['suppress_filters'] ) 
    2403                         $this->posts = apply_filters('the_posts', $this->posts); 
     2402                        $this->posts = apply_filters('the_posts', $this->posts, &$this); 
    24042403 
    24052404                $this->post_count = count($this->posts); 
    24062405