631 | | if ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
632 | | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); |
| 631 | $can_view_private_comments = current_user_can('read_private_posts') |
| 632 | || current_user_can('read_private_pages') |
| 633 | || current_user_can('edit_posts') |
| 634 | || current_user_can('edit_pages'); |
| 635 | |
| 636 | if ( $can_view_private_comments ) { |
| 637 | $comments = $wpdb->get_results("SELECT $wpdb->comments.* FROM $wpdb->comments JOIN $wpdb->posts ON ID = comment_post_ID AND ( post_type = 'post' AND " . get_private_posts_cap_sql('post') . " OR post_type = 'page' AND " . get_private_posts_cap_sql('page') . " ) WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); |
| 638 | } elseif ( !$comments = wp_cache_get( 'recent_comments', 'widget' ) ) { |
| 639 | $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments JOIN wpdb->posts ON ID = comment_post_ID AND ( post_type = 'post' AND " . get_private_posts_cap_sql('post') . " OR post_type = 'page' AND " . get_private_posts_cap_sql('page') . " ) WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 15"); |