WordPress.org

Make WordPress Core

Ticket #17024: get-approved-comments_filter_3.2.patch

File get-approved-comments_filter_3.2.patch, 831 bytes (added by kevinB, 7 years ago)

query filter for get_approved_comments()

  • wp-includes/comment.php

     
    107107 */
    108108function get_approved_comments($post_id) {
    109109        global $wpdb;
    110         return $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id));
     110        return $wpdb->get_results( apply_filters( 'get_approved_comments_query', $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id ), $post_id ) );
    111111}
    112112
    113113/**
     
    475475                }
    476476        }
    477477
    478         return $comment_count;
     478        return apply_filters( 'get_comment_count', $comment_count, $post_id );
    479479}
    480480
    481481//