wp_dashboard_recent_posts

The timeline below displays how wordpress function wp_dashboard_recent_posts has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.3

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => (int) $args['max'], 'no_found_rows' => true, 'cache_results' => true, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (gmdate('Y-m-d', $time) === $today) {
                $relative = __('Today');
            } elseif (gmdate('Y-m-d', $time) === $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (gmdate('Y', $time) !== $year) {
                /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: Relative date, 2: Time. */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: Post title. */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 5.8

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => (int) $args['max'], 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (gmdate('Y-m-d', $time) === $today) {
                $relative = __('Today');
            } elseif (gmdate('Y-m-d', $time) === $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (gmdate('Y', $time) !== $year) {
                /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: Relative date, 2: Time. */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: Post title. */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 5.6

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => (int) $args['max'], 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (gmdate('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (gmdate('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (gmdate('Y', $time) !== $year) {
                /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: Relative date, 2: Time. */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: Post title. */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 5.4

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (gmdate('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (gmdate('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (gmdate('Y', $time) !== $year) {
                /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: Relative date, 2: Time. */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: Post title. */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 5.3

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (gmdate('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (gmdate('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (gmdate('Y', $time) !== $year) {
                /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: Date and time format for recent posts on the dashboard, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: Relative date, 2: Time. */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: Post title. */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 5.2

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = current_time('Y-m-d');
        $tomorrow = gmdate('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        $year = current_time('Y');
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (date('Y', $time) !== $year) {
                /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: relative date, 2: time */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: post title */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 4.6

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filters the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (date('Y', $time) !== date('Y', current_time('timestamp'))) {
                /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: relative date, 2: time */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: post title */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 4.5

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filter the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (date('Y', $time) !== date('Y', current_time('timestamp'))) {
                /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see http://php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            $draft_or_post_title = _draft_or_post_title();
            printf(
                '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>',
                /* translators: 1: relative date, 2: time */
                sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()),
                $recent_post_link,
                /* translators: %s: post title */
                esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $draft_or_post_title)),
                $draft_or_post_title
            );
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 4.4

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filter the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h3>' . $args['title'] . '</h3>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } elseif (date('Y', $time) !== date('Y', current_time('timestamp'))) {
                /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see http://php.net/date */
                $relative = date_i18n(__('M jS Y'), $time);
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            /* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */
            $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
            printf("<li>{$format}</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title());
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 4.2

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    /**
     * Filter the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            /* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */
            $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
            printf("<li>{$format}</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title());
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 4.0

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            if (current_user_can('edit_post', get_the_ID())) {
                /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
                $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
                printf("<li>{$format}</li>", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title());
            } else {
                /* translators: 1: relative date, 2: time, 3: post title */
                $format = __('<span>%1$s, %2$s</span> %3$s');
                printf("<li>{$format}</li>", $relative, get_the_time(), _draft_or_post_title());
            }
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 3.9

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => ('future' === $args['status']) ? 'editable' : 'readable');
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $i = 0;
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            if (current_user_can('edit_post', get_the_ID())) {
                /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
                $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
                printf("<li>{$format}</li>", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title());
            } else {
                /* translators: 1: relative date, 2: time, 3: post title */
                $format = __('<span>%1$s, %2$s</span> %3$s');
                printf("<li>{$format}</li>", $relative, get_the_time(), _draft_or_post_title());
            }
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}

WordPress Version: 3.8

/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $display Number of posts to display.
 *     @type int    $max     Maximum number of posts to query.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        if ($posts->post_count > $args['display']) {
            echo '<small class="show-more hide-if-no-js"><a href="#">' . sprintf(__('See %s more&hellip;'), $posts->post_count - intval($args['display'])) . '</a></small>';
        }
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $i = 0;
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            $text = sprintf(
                /* translators: 1: relative date, 2: time, 4: post title */
                __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>'),
                $relative,
                get_the_time(),
                get_edit_post_link(),
                _draft_or_post_title()
            );
            $hidden = ($i >= $args['display']) ? ' class="hidden"' : '';
            echo "<li{$hidden}>{$text}</li>";
            $i++;
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}