Make WordPress Core

Ticket #45883: 45883.diff

File 45883.diff, 924 bytes (added by audrasjb, 7 years ago)

Add private posts to recent posts widget query if the user is connected.

  • src/wp-includes/widgets/class-wp-widget-recent-posts.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-recent-posts.php b/src/wp-includes/widgets/class-wp-widget-recent-posts.php
    index c137849..03c307e 100644
    a b class WP_Widget_Recent_Posts extends WP_Widget { 
    5656                }
    5757                $show_date = isset( $instance['show_date'] ) ? $instance['show_date'] : false;
    5858
     59                $post_status = array( 'publish' );
     60                if ( is_user_logged_in() ) {
     61                        $post_status[] = 'private';
     62                }
     63
    5964                /**
    6065                 * Filters the arguments for the Recent Posts widget.
    6166                 *
    class WP_Widget_Recent_Posts extends WP_Widget { 
    7378                                array(
    7479                                        'posts_per_page'      => $number,
    7580                                        'no_found_rows'       => true,
    76                                         'post_status'         => 'publish',
     81                                        'post_status'         => $post_status,
    7782                                        'ignore_sticky_posts' => true,
    7883                                ),
    7984                                $instance