From 3d3fe657984c492b1b49b7e8a7bd96e9ef77d012 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 1 Jun 2011 19:23:19 +0000 Subject: [PATCH] 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 --- wp-admin/admin-ajax.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index e004908f62..66a3c47533 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -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 );