WordPress.org

Make WordPress Core

Ticket #12219: ticket-12219_wp30_recent-comments-widget_attachment-comments.patch

File ticket-12219_wp30_recent-comments-widget_attachment-comments.patch, 984 bytes (added by tfnab, 9 years ago)

Patch

  • wp-includes/default-widgets.php

     
    634634                        $number = 15;
    635635
    636636                if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
    637                         $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");
     637                        $comments = $wpdb->get_results("SELECT c.* FROM $wpdb->comments c JOIN $wpdb->posts p ON p.ID = c.comment_post_ID LEFT JOIN $wpdb->posts a ON a.ID = p.post_parent WHERE c.comment_approved = '1' AND ( p.post_status = 'publish' OR ( p.post_type = 'attachment' AND a .post_status = 'publish' )) ORDER BY comment_date_gmt DESC LIMIT 15");
    638638                        wp_cache_add( 'recent_comments', $comments, 'widget' );
    639639                }
    640640