Don't update a blog's last_updated time for all post deletions. Update only when published posts are deleted.

Props SergeyBiryukov
fixes #20433


git-svn-id: http://svn.automattic.com/wordpress/trunk@20461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-04-13 17:30:37 +00:00
parent 64303ca4e8
commit f86bf75b34
2 changed files with 22 additions and 1 deletions

View File

@ -710,3 +710,24 @@ function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) {
wpmu_update_blogs_date(); wpmu_update_blogs_date();
} }
/**
* Handler for updating the blog date when a published post is deleted.
*
* @since 3.4.0
*
* @param int $post_id Post ID
*/
function _update_blog_date_on_post_delete( $post_id ) {
$post = get_post( $post_id );
$post_type_obj = get_post_type_object( $post->post_type );
if ( ! $post_type_obj->public )
return;
if ( 'publish' != $post->post_status )
return;
wpmu_update_blogs_date();
}

View File

@ -35,7 +35,7 @@ add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
// Administration // Administration
add_filter( 'term_id_filter', 'global_terms', 10, 2 ); add_filter( 'term_id_filter', 'global_terms', 10, 2 );
add_action( 'publish_post', 'update_posts_count' ); add_action( 'publish_post', 'update_posts_count' );
add_action( 'delete_post', 'wpmu_update_blogs_date' ); add_action( 'delete_post', '_update_blog_date_on_post_delete' );
add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
add_action( 'admin_init', 'wp_schedule_update_network_counts'); add_action( 'admin_init', 'wp_schedule_update_network_counts');
add_action( 'update_network_counts', 'wp_update_network_counts'); add_action( 'update_network_counts', 'wp_update_network_counts');