_update_posts_count_on_transition_post_status

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

WordPress Version: 4.9

/**
 * Handler for updating the current site's posts count when a post status changes.
 *
 * @since 4.0.0
 * @since 4.9.0 Added the `$post` parameter.
 *
 * @param string  $new_status The status the post is changing to.
 * @param string  $old_status The status the post is changing from.
 * @param WP_Post $post       Post object
 */
function _update_posts_count_on_transition_post_status($new_status, $old_status, $post = null)
{
    if ($new_status === $old_status) {
        return;
    }
    if ('post' !== get_post_type($post)) {
        return;
    }
    if ('publish' !== $new_status && 'publish' !== $old_status) {
        return;
    }
    update_posts_count();
}

WordPress Version: 4.0

/**
 * Handler for updating the blog posts count date when a post status changes.
 *
 * @since 4.0.0
 *
 * @param string $new_status The status the post is changing to.
 * @param string $old_status The status the post is changing from.
 */
function _update_posts_count_on_transition_post_status($new_status, $old_status)
{
    if ($new_status === $old_status) {
        return;
    }
    if ('publish' !== $new_status && 'publish' !== $old_status) {
        return;
    }
    update_posts_count();
}