Ticket #9211: widgets.3.diff

File widgets.3.diff, 1.1 KB (added by mrmist, 4 years ago)

adds the attachement post type

Line 
1Index: widgets.php
2===================================================================
3--- widgets.php (revision 10626)
4+++ widgets.php (working copy)
5@@ -1388,8 +1388,11 @@
6        else if ( $number > 15 )
7                $number = 15;
8 
9+       $can_read_priv_posts = current_user_can('read_private_posts') ? " OR (p.post_status = 'private' and p.post_type = 'post') " : "";
10+       $can_read_priv_pages = current_user_can('read_private_pages') ? " OR (p.post_status = 'private' and p.post_type = 'page') " : "";
11+
12        if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) {
13-               $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
14+               $comments = $wpdb->get_results("SELECT c.* FROM $wpdb->comments c inner join $wpdb->posts p on c.comment_post_id = p.ID WHERE c.comment_approved = '1' AND (p.post_status = 'publish' OR ( post_status = 'inherit' and post_type = 'attachment' ) $can_read_priv_posts $can_read_priv_pages ) ORDER BY comment_date_gmt DESC LIMIT $number");
15                wp_cache_add( 'recent_comments', $comments, 'widget' );
16        }
17 ?>