Make WordPress Core

Ticket #35060: 35060.diff

File 35060.diff, 879 bytes (added by swissspidy, 9 years ago)
  • src/wp-includes/comment.php

    diff --git src/wp-includes/comment.php src/wp-includes/comment.php
    index a84f0a7..b64fda3 100644
    function wp_update_comment_count_now($post_id) { 
    20522052
    20532053        $old = (int) $post->comment_count;
    20542054        $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post_id) );
     2055
     2056        /**
     2057         * Filters a post's comment count before it is updated in the database.
     2058         *
     2059         * @since 4.5.0
     2060         *
     2061         * @param int $post_id Post ID.
     2062         * @param int $new     The new comment count.
     2063         * @param int $old     The old comment count.
     2064         */
     2065        $new = (int) apply_filters( 'wp_update_comment_count_new', $post_id, $new, $old );
     2066
    20552067        $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post_id) );
    20562068
    20572069        clean_post_cache( $post );