WordPress.org

Make WordPress Core

Ticket #42021: 42021.diff

File 42021.diff, 1.7 KB (added by spacedmonkey, 3 years ago)
  • src/wp-includes/ms-blogs.php

     
    12991299 *
    13001300 * @since 4.0.0
    13011301 *
    1302  * @param string $new_status The status the post is changing to.
    1303  * @param string $old_status The status the post is changing from.
     1302 * @param string  $new_status The status the post is changing to.
     1303 * @param string  $old_status The status the post is changing from.
     1304 * @param WP_Post $post       Post object
    13041305 */
    1305 function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
     1306function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) {
    13061307        if ( $new_status === $old_status ) {
    13071308                return;
    13081309        }
    13091310
     1311        // update_posts_count() only looks for the 'post' post type, so skip any other type.
     1312        if ( 'post' !== get_post_type( $post ) ) {
     1313                return;
     1314        }
     1315
    13101316        if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
    13111317                return;
    13121318        }
  • src/wp-includes/ms-default-filters.php

     
    5454add_action( 'delete_post', '_update_posts_count_on_delete' );
    5555add_action( 'delete_post', '_update_blog_date_on_post_delete' );
    5656add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
    57 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 );
     57add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
    5858
    5959// Counts
    6060add_action( 'admin_init', 'wp_schedule_update_network_counts');