Changeset 33662
- Timestamp:
- 08/20/2015 04:35:21 PM (9 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r33655 r33662 358 358 'supplemental' => array( 359 359 'status' => $comment ? $comment->comment_approved : '', 360 'postId' => $comment ? $comment->comment_post_ID : '', 360 361 'time' => $time 361 362 ) … … 399 400 'supplemental' => array( 400 401 'status' => $comment ? $comment->comment_approved : '', 402 'postId' => $comment ? $comment->comment_post_ID : '', 401 403 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 402 404 'total_pages' => ceil( $total / $per_page ), … … 1043 1045 1044 1046 if ( $comment_auto_approved ) 1045 $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );1047 $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID, 'parent_post_id' => $parent->comment_post_ID ); 1046 1048 1047 1049 $x = new WP_Ajax_Response(); -
trunk/src/wp-admin/includes/class-wp-comments-list-table.php
r33657 r33662 412 412 <?php 413 413 $this->items = $this->extra_items; 414 $this->display_rows_or_placeholder(); 414 $this->display_rows_or_placeholder(); 415 415 ?> 416 416 </tbody> … … 699 699 $post_type_object = get_post_type_object( $post->post_type ); 700 700 echo "<a href='" . get_permalink( $post->ID ) . "' class='comments-view-item-link'>" . $post_type_object->labels->view_item . '</a>'; 701 echo '<span class="post-com-count-wrapper ">';701 echo '<span class="post-com-count-wrapper post-com-count-', $post->ID, '">'; 702 702 $this->comments_bubble( $post->ID, $pending_comments ); 703 703 echo '</span> '; -
trunk/src/wp-admin/includes/class-wp-list-table.php
r33623 r33662 648 648 $pending_comments_number, 649 649 $pending_phrase 650 ); 651 } else { 652 printf( '<span class="post-com-count post-com-count-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', 653 $pending_comments_number, 654 $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) 650 655 ); 651 656 } -
trunk/src/wp-admin/js/edit-comments.js
r33660 r33662 3 3 4 4 (function($) { 5 var getCount, updateCount, updateCountText, updatePending ;5 var getCount, updateCount, updateCountText, updatePending, updateApproved; 6 6 7 7 setCommentsList = function() { … … 15 15 // this fires when viewing "All" 16 16 dimAfter = function( r, settings ) { 17 var editRow, replyID, replyButton, 17 var editRow, replyID, replyButton, response, 18 18 c = $( '#' + settings.element ); 19 19 … … 35 35 36 36 diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; 37 updatePending( diff ); 38 updateCountText( 'span.approved-count', -1 * diff ); 39 updateCountText( 'span.comment-count-approved', -1 * diff ); 37 if ( true !== settings.parsed && settings.parsed.responses.length ) { 38 response = settings.parsed.responses[0].supplemental; 39 updatePending( diff, response.postId ); 40 updateApproved( -1 * diff, response.postId ); 41 } else { 42 updatePending( diff ); 43 updateApproved( -1 * diff ); 44 } 40 45 }; 41 46 … … 131 136 }; 132 137 133 updatePending = function( diff ) { 134 $('span.pending-count, .comment-count-pending').each(function() { 138 updatePending = function( diff, commentPostId ) { 139 var postSelector = '.post-com-count-' + commentPostId, 140 noClass = 'comment-count-no-pending', 141 pendingClass = 'comment-count-pending', 142 counts = $( 'span.pending-count' ), 143 pending, 144 noPending; 145 146 counts.each(function() { 135 147 var a = $(this), n = getCount(a) + diff; 136 148 if ( n < 1 ) … … 139 151 updateCount( a, n ); 140 152 }); 153 154 if ( ! commentPostId ) { 155 return; 156 } 157 158 // cache selectors to not get dupes 159 pending = $( 'span.' + pendingClass, postSelector ); 160 noPending = $( 'span.' + noClass, postSelector ); 161 162 pending.each(function() { 163 var a = $(this), n = getCount(a) + diff; 164 if ( n < 1 ) 165 n = 0; 166 167 if ( 0 === n ) { 168 a.removeClass( pendingClass ).addClass( noClass ); 169 } 170 updateCount( a, n ); 171 }); 172 173 noPending.each(function() { 174 var a = $(this); 175 if ( diff > 0 ) { 176 a.removeClass( noClass ).addClass( pendingClass ); 177 } 178 updateCount( a, diff ); 179 }); 180 }; 181 182 updateApproved = function( diff, commentPostId ) { 183 var postSelector = '.post-com-count-' + commentPostId, 184 noClass = 'comment-count-no-comments', 185 approvedClass = 'comment-count-approved', 186 approved, 187 noComments; 188 189 updateCountText( 'span.approved-count', diff ); 190 191 if ( ! commentPostId ) { 192 return; 193 } 194 195 // cache selectors to not get dupes 196 approved = $( 'span.' + approvedClass, postSelector ); 197 noComments = $( 'span.' + noClass, postSelector ); 198 199 approved.each(function() { 200 var a = $(this), n = getCount(a) + diff; 201 if ( n < 1 ) 202 n = 0; 203 204 if ( 0 === n ) { 205 a.removeClass( approvedClass ).addClass( noClass ); 206 } 207 updateCount( a, n ); 208 }); 209 210 noComments.each(function() { 211 var a = $(this); 212 if ( diff > 0 ) { 213 a.removeClass( noClass ).addClass( approvedClass ); 214 } 215 updateCount( a, diff ); 216 }); 141 217 }; 142 218 … … 153 229 // In admin-ajax.php, we send back the unix time stamp instead of 1 on success 154 230 delAfter = function( r, settings ) { 155 var total_items_i18n, total, animated, animatedCallback, 231 var total_items_i18n, total, animated, animatedCallback, postSelector, 156 232 response = true === settings.parsed ? {} : settings.parsed.responses[0], 157 233 commentStatus = true === settings.parsed ? '' : response.supplemental.status, 234 commentPostId = true === settings.parsed ? '' : response.supplemental.postId, 158 235 159 236 targetParent = $( settings.target ).parent(), … … 286 363 } 287 364 365 postSelector = '.post-com-count-' + commentPostId; 366 288 367 if ( pendingDiff ) { 289 updatePending( pendingDiff );368 updatePending( pendingDiff, commentPostId ); 290 369 } 291 370 292 371 if ( approvedDiff ) { 293 updateCountText( 'span.approved-count', approvedDiff ); 294 updateCountText( 'span.comment-count-approved', approvedDiff ); 372 updateApproved( approvedDiff, commentPostId ); 295 373 } 296 374 … … 338 416 refillTheExtraList(); 339 417 340 animated = $( ':animated' );418 animated = $( ':animated', '#the-comment-list' ); 341 419 animatedCallback = function () { 342 420 if ( ! $( '#the-comment-list tr:visible' ).length ) { … … 628 706 if ( r.supplemental.parent_approved ) { 629 707 pid = $('#comment-' + r.supplemental.parent_approved); 630 updatePending( -1 );708 updatePending( -1, r.supplemental.parent_post_id ); 631 709 632 710 if ( this.comments_listing == 'moderated' ) {
Note: See TracChangeset
for help on using the changeset viewer.