WordPress.org

Make WordPress Core

Ticket #9635: comment_query_filters.9635.diff

File comment_query_filters.9635.diff, 1.9 KB (added by filosofo, 5 years ago)
  • wp-includes/query.php

     
    21862186                                $cjoin = apply_filters('comment_feed_join', $cjoin); 
    21872187                                $cwhere = apply_filters('comment_feed_where', $cwhere); 
    21882188                                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 
     2189                                $corderby = apply_filters('comment_feed_orderby', 'ORDER BY comment_date_gmt DESC'); 
     2190                                $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
    21892191                        } 
    21902192 
    2191                         $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss')); 
     2193                        $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"); 
    21922194                        $this->comment_count = count($this->comments); 
    21932195 
    21942196                        $post_ids = array(); 
     
    22532255                if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) { 
    22542256                        $cjoin = apply_filters('comment_feed_join', ''); 
    22552257                        $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); 
    2256                         $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); 
     2258                        $cgroupby = apply_filters('comment_feed_groupby', ''); 
     2259                        $corderby = apply_filters('comment_feed_orderby', 'ORDER BY comment_date_gmt DESC'); 
     2260                        $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2261                        $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 
    22572262                        $this->comments = $wpdb->get_results($comments_request); 
    22582263                        $this->comment_count = count($this->comments); 
    22592264                }