From eb835e190165ddcd2ad43056f95c83bd2ade8448 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 3 Nov 2011 17:06:45 +0000 Subject: [PATCH] Update the blog date whenever a pubic post type is published or changed after being published. fixes #18624 git-svn-id: http://svn.automattic.com/wordpress/trunk@19129 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-blogs.php | 22 ++++++++++++++++++++++ wp-includes/ms-default-filters.php | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/wp-includes/ms-blogs.php b/wp-includes/ms-blogs.php index 3668afcac8..0bd6a92b85 100644 --- a/wp-includes/ms-blogs.php +++ b/wp-includes/ms-blogs.php @@ -687,4 +687,26 @@ function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) { return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A ); } +/** + * Handler for updating the blog date when a post is published or an already published post is changed. + * + * @since 3.3.0 + * + * @param string $new_status The new post status + * @param string $old_status The old post status + * @param object $post Post object + */ +function _update_blog_date_on_post_publish( $new_status, $old_status, $post ) { + $post_type_obj = get_post_type_object( $post->post_type ); + if ( ! $post_type_obj->public ) + return; + + if ( 'publish' != $new_status && 'publish' != $old_status ) + return; + + // Post was freshly published, published post was saved, or published post was unpublished. + + wpmu_update_blogs_date(); +} + ?> diff --git a/wp-includes/ms-default-filters.php b/wp-includes/ms-default-filters.php index f2fd68f7a6..9e42f62d21 100644 --- a/wp-includes/ms-default-filters.php +++ b/wp-includes/ms-default-filters.php @@ -36,7 +36,7 @@ add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); 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( 'publish_post', 'wpmu_update_blogs_date' ); +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');