diff --git a/src/js/_enqueues/admin/edit-comments.js b/src/js/_enqueues/admin/edit-comments.js index 78ee78de759ff..ccb49da74ceed 100644 --- a/src/js/_enqueues/admin/edit-comments.js +++ b/src/js/_enqueues/admin/edit-comments.js @@ -480,12 +480,13 @@ window.setCommentsList = function() { response = true === settings.parsed ? {} : settings.parsed.responses[0], commentStatus = true === settings.parsed ? '' : response.supplemental.status, commentPostId = true === settings.parsed ? '' : response.supplemental.postId, + isCurrentUserComment = true === settings.parsed ? false : !! parseInt( response.supplemental.isCurrentUserComment, 10 ), newTotal = true === settings.parsed ? '' : response.supplemental, targetParent = $( settings.target ).parent(), commentRow = $('#' + settings.element), - spamDiff, trashDiff, pendingDiff, approvedDiff, + spamDiff, trashDiff, pendingDiff, approvedDiff, mineDiff, /* * As `wpList` toggles only the `unapproved` class, the approved comment @@ -623,6 +624,11 @@ window.setCommentsList = function() { } } + mineDiff = ( pendingDiff || 0 ) + ( approvedDiff || 0 ); + if ( mineDiff && isCurrentUserComment ) { + updateCountText( 'span.mine-count', mineDiff ); + } + if ( pendingDiff ) { updatePending( pendingDiff, commentPostId ); updateCountText( 'span.all-count', pendingDiff ); @@ -1155,6 +1161,7 @@ window.commentReply = { updateInModerationText( r.supplemental ); updateApproved( 1, r.supplemental.parent_post_id ); updateCountText( 'span.all-count', 1 ); + updateCountText( 'span.mine-count', 1 ); } r.data = r.data || ''; diff --git a/src/wp-admin/includes/ajax-actions.php b/src/wp-admin/includes/ajax-actions.php index a04de73bd64e4..8fca8c2fe8f10 100644 --- a/src/wp-admin/includes/ajax-actions.php +++ b/src/wp-admin/includes/ajax-actions.php @@ -488,6 +488,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 'supplemental' => array( 'status' => $comment_status, 'postId' => $comment ? $comment->comment_post_ID : '', + 'isCurrentUserComment' => (int) ( $comment && get_current_user_id() === (int) $comment->user_id ), 'time' => $time, 'in_moderation' => $counts->moderated, 'i18n_comments_text' => sprintf( @@ -559,6 +560,7 @@ function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 'supplemental' => array( 'status' => $comment ? $comment->comment_approved : '', 'postId' => $comment ? $comment->comment_post_ID : '', + 'isCurrentUserComment' => (int) ( $comment && get_current_user_id() === (int) $comment->user_id ), /* translators: %s: Number of comments. */ 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 'total_pages' => (int) ceil( $total / $per_page ),