Ticket #27952: 27952.2.diff
File 27952.2.diff, 2.6 KB (added by , 10 years ago) |
---|
-
wp-includes/ms-functions.php
1761 1761 * WordPress MS stores a blog's post count as an option so as 1762 1762 * to avoid extraneous COUNTs when a blog's details are fetched 1763 1763 * with get_blog_details(). This function is called when posts 1764 * are published to make sure the count stays current.1764 * are published or unpublished to make sure the count stays current. 1765 1765 * 1766 1766 * @since MU 1767 1767 */ -
wp-includes/ms-default-filters.php
34 34 35 35 // Administration 36 36 add_filter( 'term_id_filter', 'global_terms', 10, 2 ); 37 add_action( ' publish_post', 'update_posts_count' );37 add_action( 'delete_post', '_update_posts_count_on_delete' ); 38 38 add_action( 'delete_post', '_update_blog_date_on_post_delete' ); 39 39 add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); 40 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 ); 40 41 41 42 // Counts 42 43 add_action( 'admin_init', 'wp_schedule_update_network_counts'); -
wp-includes/ms-blogs.php
892 892 wpmu_update_blogs_date(); 893 893 } 894 894 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 */ 902 function _update_posts_count_on_delete($post_id) 903 { 904 //First check if this was a published post. 905 $post = get_post($post_id); 906 if($post->post_status != "publish") 907 return; 908 909 //Must be pusblished. Update the posts count. 910 update_posts_count(); 911 } 912 913 /** 914 * Handler for updating the blog posts count date when a post status changes. 915 * 916 * @since 4.0 917 * 918 * @param string $new_status The status the post is changing to. 919 * @param string $old_status The status the post is changing from. 920 */ 921 function _update_posts_count_on_transition_post_status($new_status, $old_status) 922 { 923 //If the status isn't really changing, we don't need to update the count. 924 if($new_status == $old_status) 925 return; 926 927 //If neither the new or old status is publish, we don't need to update the count. 928 if($new_status != "publish" && $old_status != "publish") 929 return; 930 931 //Okay. Update the posts count. 932 update_posts_count(); 933 } 934