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

Adds unit test.

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


git-svn-id: https://develop.svn.wordpress.org/trunk@28835 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2014-06-26 00:52:25 +00:00
parent 8621b2c92c
commit b917e7998d
4 changed files with 50 additions and 2 deletions
+35
View File
@@ -892,3 +892,38 @@ function _update_blog_date_on_post_delete( $post_id ) {
wpmu_update_blogs_date();
}
/**
* Handler for updating the blog posts count date when a post is deleted.
*
* @since 4.0
*
* @param int $post_id Post ID
*/
function _update_posts_count_on_delete( $post_id ) {
if ( 'publish' !== get_post_field( 'post_status', $post_id ) ) {
return;
}
update_posts_count();
}
/**
* Handler for updating the blog posts count date when a post status changes.
*
* @since 4.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();
}