WordPress.org

Make WordPress Core

Ticket #17020: comment-filters_3.2.patch

File comment-filters_3.2.patch, 1.9 KB (added by kevinB, 9 years ago)

query filters for wp_dashboard_recent_comments() and get_approved_comments()

  • wp-admin/includes/comment.php

     
    115115        $post_id_array = array_map('intval', $post_id_array);
    116116        $post_id_in = "'" . implode("', '", $post_id_array) . "'";
    117117
    118         $pending = $wpdb->get_results( "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", ARRAY_A );
     118        $pending = $wpdb->get_results( apply_filters( 'pending_comments_query', "SELECT comment_post_ID, COUNT(comment_ID) as num_comments FROM $wpdb->comments WHERE comment_post_ID IN ( $post_id_in ) AND comment_approved = '0' GROUP BY comment_post_ID", $post_id ), ARRAY_A );
    119119
    120120        if ( $single ) {
    121121                if ( empty($pending) )
  • wp-admin/includes/dashboard.php

     
    609609        $total_items = isset( $widgets['dashboard_recent_comments'] ) && isset( $widgets['dashboard_recent_comments']['items'] )
    610610                ? absint( $widgets['dashboard_recent_comments']['items'] ) : 5;
    611611
    612         while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) {
     612        while ( count( $comments ) < $total_items && $possible = $wpdb->get_results( apply_filters( 'dashboard_recent_comments_query', "SELECT * FROM $wpdb->comments c LEFT JOIN $wpdb->posts p ON c.comment_post_ID = p.ID WHERE p.post_status != 'trash' ORDER BY c.comment_date_gmt DESC LIMIT $start, 50" ) ) ) {
    613613
    614614                foreach ( $possible as $comment ) {
    615615                        if ( count( $comments ) >= $total_items )