WordPress.org

Make WordPress Core

Ticket #9211: 9211.2.diff

File 9211.2.diff, 778 bytes (added by Denis-de-Bernardy, 6 years ago)

strip out comments on non-public posts

  • wp-includes/default-widgets.php

     
    632632                        $number = 15; 
    633633 
    634634                if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { 
    635                         $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); 
     635                        $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->comments.comment_post_ID WHERE comment_approved = '1' AND post_status = 'publish' ORDER BY comment_date_gmt DESC LIMIT 15"); 
    636636                        wp_cache_add( 'recent_comments', $comments, 'widget' ); 
    637637                } 
    638638