Decrement pending count after Approve and Reply. Props DH-Shredder. fixes #17380

git-svn-id: http://svn.automattic.com/wordpress/trunk@18100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2011-06-01 19:23:19 +00:00
parent e2a2e5edf8
commit 3d3fe65798
1 changed files with 14 additions and 9 deletions

View File

@ -660,6 +660,7 @@ case 'replyto-comment' :
die( __('Error: please type a comment.') );
$comment_parent = absint($_POST['comment_ID']);
$comment_auto_approved = false;
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');
$comment_id = wp_new_comment( $commentdata );
@ -668,6 +669,17 @@ case 'replyto-comment' :
$position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';
// automatically approve parent comment
if ( !empty($_POST['approve_parent']) ) {
$parent = get_comment( $comment_parent );
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
$comment_auto_approved = true;
}
}
ob_start();
if ( 'dashboard' == $_REQUEST['mode'] ) {
require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
@ -690,15 +702,8 @@ case 'replyto-comment' :
'position' => $position
);
// automatically approve parent comment
if ( !empty($_POST['approve_parent']) ) {
$parent = get_comment( $comment_parent );
if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );
}
}
if ( $comment_auto_approved )
$response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );
$x = new WP_Ajax_Response();
$x->add( $response );