wp_update_comment_count hook from mdawaffe. fixes #4740
git-svn-id: http://svn.automattic.com/wordpress/trunk@5869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2ae70d7c72
commit
ddc05f60ea
|
@ -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