WordPress.org

Make WordPress Core

Changeset 11211


Ignore:
Timestamp:
05/05/09 22:41:26 (5 years ago)
Author:
ryan
Message:

Comment query filters. Props filosofo. fixes #9635

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r11141 r11211  
    21712171                $cjoin = "LEFT JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) $join "; 
    21722172                $cwhere = "WHERE comment_approved = '1' $where"; 
    2173                 $cgroupby = "GROUP BY $wpdb->comments.comment_id"; 
     2173                $cgroupby = "$wpdb->comments.comment_id"; 
    21742174            } else { // Other non singular e.g. front 
    21752175                $cjoin = "LEFT JOIN $wpdb->posts ON ( $wpdb->comments.comment_post_ID = $wpdb->posts.ID )"; 
     
    21822182                $cwhere = apply_filters('comment_feed_where', $cwhere); 
    21832183                $cgroupby = apply_filters('comment_feed_groupby', $cgroupby); 
    2184             } 
    2185  
    2186             $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')); 
     2184                $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2185                $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2186            } 
     2187            $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
     2188            $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
     2189 
     2190            $this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"); 
    21872191            $this->comment_count = count($this->comments); 
    21882192 
     
    22492253            $cjoin = apply_filters('comment_feed_join', ''); 
    22502254            $cwhere = apply_filters('comment_feed_where', "WHERE comment_post_ID = '{$this->posts[0]->ID}' AND comment_approved = '1'"); 
    2251             $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'); 
     2255            $cgroupby = apply_filters('comment_feed_groupby', ''); 
     2256            $cgroupby = ( ! empty( $cgroupby ) ) ? 'GROUP BY ' . $cgroupby : ''; 
     2257            $corderby = apply_filters('comment_feed_orderby', 'comment_date_gmt DESC'); 
     2258            $corderby = ( ! empty( $corderby ) ) ? 'ORDER BY ' . $corderby : ''; 
     2259            $climits = apply_filters('comment_feed_limits', 'LIMIT ' . get_option('posts_per_rss')); 
     2260            $comments_request = "SELECT $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby $corderby $climits"; 
    22522261            $this->comments = $wpdb->get_results($comments_request); 
    22532262            $this->comment_count = count($this->comments); 
Note: See TracChangeset for help on using the changeset viewer.