WordPress.org

Make WordPress Core

Ticket #42021: 42021.2.diff

File 42021.2.diff, 2.0 KB (added by jeremyfelt, 2 years ago)
  • src/wp-includes/ms-blogs.php

     
    12851285function _update_posts_count_on_delete( $post_id ) {
    12861286        $post = get_post( $post_id );
    12871287
    1288         if ( ! $post || 'publish' !== $post->post_status ) {
     1288        if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
    12891289                return;
    12901290        }
    12911291
     
    12961296 * Handler for updating the blog posts count date when a post status changes.
    12971297 *
    12981298 * @since 4.0.0
     1299 * @since 4.9.0 Added the `$post` parameter.
    12991300 *
    1300  * @param string $new_status The status the post is changing to.
    1301  * @param string $old_status The status the post is changing from.
     1301 * @param string  $new_status The status the post is changing to.
     1302 * @param string  $old_status The status the post is changing from.
     1303 * @param WP_Post $post       Post object
    13021304 */
    1303 function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
     1305function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post = null ) {
    13041306        if ( $new_status === $old_status ) {
    13051307                return;
    13061308        }
    13071309
     1310        if ( 'post' !== get_post_type( $post ) ) {
     1311                return;
     1312        }
     1313
    13081314        if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
    13091315                return;
    13101316        }
  • 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');