diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php
index 289d959224..c380583207 100644
--- a/src/wp-admin/includes/ajax-actions.php
+++ b/src/wp-admin/includes/ajax-actions.php
@@ -351,6 +351,8 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
$time = time();
$comment = get_comment( $comment_id );
+ $counts = wp_count_comments();
+
$x = new WP_Ajax_Response( array(
'what' => 'comment',
// Here for completeness - not used.
@@ -358,7 +360,16 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) {
'supplemental' => array(
'status' => $comment ? $comment->comment_approved : '',
'postId' => $comment ? $comment->comment_post_ID : '',
- 'time' => $time
+ 'time' => $time,
+ 'in_moderation' => $counts->moderated,
+ 'i18n_comments_text' => sprintf(
+ _n( '%s Comment', '%s Comments', $counts->approved ),
+ number_format_i18n( $counts->approved )
+ ),
+ 'i18n_moderation_text' => sprintf(
+ _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
+ number_format_i18n( $counts->moderated )
+ )
)
) );
$x->send();
@@ -1049,8 +1060,23 @@ function wp_ajax_replyto_comment( $action ) {
'position' => $position
);
- if ( $comment_auto_approved )
- $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID );
+ $counts = wp_count_comments();
+ $response['supplemental'] = array(
+ 'in_moderation' => $counts->moderated,
+ 'i18n_comments_text' => sprintf(
+ _n( '%s Comment', '%s Comments', $counts->approved ),
+ number_format_i18n( $counts->approved )
+ ),
+ 'i18n_moderation_text' => sprintf(
+ _nx( '%s in moderation', '%s in moderation', $counts->moderated, 'comments' ),
+ number_format_i18n( $counts->moderated )
+ )
+ );
+
+ if ( $comment_auto_approved ) {
+ $response['supplemental']['parent_approved'] = $parent->comment_ID;
+ $response['supplemental']['parent_post_id'] = $parent->comment_post_ID;
+ }
$x = new WP_Ajax_Response();
$x->add( $response );
diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php
index 806f6d938b..f09c7796b5 100644
--- a/src/wp-admin/includes/dashboard.php
+++ b/src/wp-admin/includes/dashboard.php
@@ -259,13 +259,15 @@ function wp_dashboard_right_now() {
?>
moderated ) {
- /* translators: Number of comments in moderation */
- $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) );
- ?>
-
- moderated, 'comments' ), number_format_i18n( $num_comm->moderated ) );
+ ?>
+
+ comment_post_ID > 0 && current_user_can( 'edit_post', $comment->comment_post_ID ) ) {
$comment_post_title = _draft_or_post_title( $comment->comment_post_ID );
diff --git a/src/wp-admin/js/edit-comments.js b/src/wp-admin/js/edit-comments.js
index e06f93a9d6..fe2a38b8e1 100644
--- a/src/wp-admin/js/edit-comments.js
+++ b/src/wp-admin/js/edit-comments.js
@@ -3,7 +3,7 @@ var setCommentsList, theList, theExtraList, commentReply;
(function($) {
var getCount, updateCount, updateCountText, updatePending, updateApproved,
- updateHtmlTitle, adminTitle = document.title;
+ updateHtmlTitle, updateDashboardText, adminTitle = document.title;
setCommentsList = function() {
var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff,
@@ -19,6 +19,10 @@ setCommentsList = function() {
var editRow, replyID, replyButton, response,
c = $( '#' + settings.element );
+ if ( true !== settings.parsed ) {
+ response = settings.parsed.responses[0];
+ }
+
editRow = $('#replyrow');
replyID = $('#comment_ID', editRow).val();
replyButton = $('#replybtn', editRow);
@@ -36,10 +40,10 @@ setCommentsList = function() {
}
diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1;
- if ( true !== settings.parsed && settings.parsed.responses.length ) {
- response = settings.parsed.responses[0].supplemental;
- updatePending( diff, response.postId );
- updateApproved( -1 * diff, response.postId );
+ if ( response ) {
+ updateDashboardText( response.supplemental );
+ updatePending( diff, response.supplemental.postId );
+ updateApproved( -1 * diff, response.supplemental.postId );
} else {
updatePending( diff );
updateApproved( -1 * diff );
@@ -277,12 +281,26 @@ setCommentsList = function() {
});
};
+ updateDashboardText = function ( response ) {
+ if ( ! isDashboard || ! response || ! response.i18n_comments_text ) {
+ return;
+ }
+
+ var rightNow = $( '#dashboard_right_now' );
+
+ $( '.comment-count a', rightNow ).text( response.i18n_comments_text );
+ $( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text )
+ .parent()
+ [ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' );
+ };
+
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success
delAfter = function( r, settings ) {
var total_items_i18n, total, animated, animatedCallback,
response = true === settings.parsed ? {} : settings.parsed.responses[0],
commentStatus = true === settings.parsed ? '' : response.supplemental.status,
commentPostId = true === settings.parsed ? '' : response.supplemental.postId,
+ newTotal = true === settings.parsed ? '' : response.supplemental,
targetParent = $( settings.target ).parent(),
commentRow = $('#' + settings.element),
@@ -294,6 +312,8 @@ setCommentsList = function() {
spammed = commentRow.hasClass( 'spam' ),
trashed = commentRow.hasClass( 'trash' );
+ updateDashboardText( newTotal );
+
// the order of these checks is important
// .unspam can also have .approve or .unapprove
// .untrash can also have .approve or .unapprove
@@ -771,6 +791,10 @@ commentReply = {
}
}
+ if ( r.supplemental.i18n_comments_text ) {
+ updateDashboardText( r.supplemental );
+ }
+
c = $.trim(r.data); // Trim leading whitespaces
$(c).hide();
$('#replyrow').after(c);