wp_update_comment_count hook from mdawaffe. fixes #4740
git-svn-id: https://develop.svn.wordpress.org/trunk@5869 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
44afc295c3
commit
3927faeee5
|
@ -500,17 +500,21 @@ function wp_update_comment_count($post_id) {
|
||||||
$post_id = (int) $post_id;
|
$post_id = (int) $post_id;
|
||||||
if ( !$post_id )
|
if ( !$post_id )
|
||||||
return false;
|
return false;
|
||||||
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
|
if ( !$post = get_post($post_id) )
|
||||||
$wpdb->query("UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$post_id'");
|
return false;
|
||||||
$comment_count_cache[$post_id] = $count;
|
|
||||||
|
$old = (int) $post->comment_count;
|
||||||
|
$new = (int) $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1'");
|
||||||
|
$wpdb->query("UPDATE $wpdb->posts SET comment_count = '$new' WHERE ID = '$post_id'");
|
||||||
|
$comment_count_cache[$post_id] = $new;
|
||||||
|
|
||||||
$post = get_post($post_id);
|
|
||||||
if ( 'page' == $post->post_type )
|
if ( 'page' == $post->post_type )
|
||||||
clean_page_cache( $post_id );
|
clean_page_cache( $post_id );
|
||||||
else
|
else
|
||||||
clean_post_cache( $post_id );
|
clean_post_cache( $post_id );
|
||||||
|
|
||||||
do_action('edit_post', $post_id);
|
do_action('wp_update_comment_count', $post_id, $new, $old);
|
||||||
|
do_action('edit_post', $post_id, $post);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue