Make WordPress Core


Ignore:
Timestamp:
06/26/2014 12:52:25 AM (10 years ago)
Author:
wonderboymusic
Message:

get_blog_details()->post_count should update on more actions than just publish_post.

Adds unit test.

Props 5um17, midxcat, strangerstudios.
Fixes #27952.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r27347 r28835  
    893893}
    894894
     895/**
     896 * Handler for updating the blog posts count date when a post is deleted.
     897 *
     898 * @since 4.0
     899 *
     900 * @param int $post_id Post ID
     901 */
     902function _update_posts_count_on_delete( $post_id ) {
     903    if ( 'publish' !== get_post_field( 'post_status', $post_id ) ) {
     904        return;
     905    }
     906   
     907    update_posts_count();
     908}
     909
     910/**
     911 * Handler for updating the blog posts count date when a post status changes.
     912 *
     913 * @since 4.0
     914 *
     915 * @param string $new_status The status the post is changing to.
     916 * @param string $old_status The status the post is changing from.
     917 */
     918function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
     919    if ( $new_status === $old_status ) {
     920        return;
     921    }
     922
     923    if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
     924        return;
     925    }
     926
     927    update_posts_count();
     928}
     929
Note: See TracChangeset for help on using the changeset viewer.