From f86bf75b344bbca8aef71df73e951863f6ae693e Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 13 Apr 2012 17:30:37 +0000 Subject: [PATCH] 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 --- wp-includes/ms-blogs.php | 21 +++++++++++++++++++++ wp-includes/ms-default-filters.php | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 1dc4eb4bca..8f66aaddc3 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -710,3 +710,24 @@ function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { 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(); +} + diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index 3922d3e13e..44d8294ac5 100644 --- a/wp-includes/ms-default-filters.php +++ b/wp-includes/ms-default-filters.php @@ -35,7 +35,7 @@ add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); // Administration add_filter( 'term_id_filter', 'global_terms', 10, 2 ); 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( 'admin_init', 'wp_schedule_update_network_counts'); add_action( 'update_network_counts', 'wp_update_network_counts');