Make WordPress Core

Ticket #42021: post_counts.diff

File post_counts.diff, 1.6 KB (added by sboisvert, 6 years ago)
  • wp-includes/ms-blogs.php

     
    13111311 *
    13121312 * @param string $new_status The status the post is changing to.
    13131313 * @param string $old_status The status the post is changing from.
     1314 * @param object $post       Post object
    13141315 */
    1315 function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
     1316function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post ) {
    13161317        if ( $new_status === $old_status ) {
    13171318                return;
    13181319        }
    13191320
     1321        if ( ! empty( $post->post_type ) && 'post' !== $post->post_type ){
     1322                return; // update_posts_count only looks for the posts post type so no need to run this when a different post type is being touched.
     1323        }
     1324
    13201325        if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
    13211326                return;
    13221327        }
  • wp-includes/ms-default-filters.php

     
    5151add_action( 'delete_post', '_update_posts_count_on_delete' );
    5252add_action( 'delete_post', '_update_blog_date_on_post_delete' );
    5353add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
    54 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 );
     54add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
    5555
    5656// Counts
    5757add_action( 'admin_init', 'wp_schedule_update_network_counts');