Ticket #11200: 11200.2.diff
File 11200.2.diff, 7.7 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
377 377 378 378 // The time since the last comment count. 379 379 $time = time(); 380 $comment = get_comment( $comment_id ); 380 381 381 382 $x = new WP_Ajax_Response( array( 382 383 'what' => 'comment', 383 384 // Here for completeness - not used. 384 385 'id' => $comment_id, 386 'data' => $comment->comment_approved, 385 387 'supplemental' => array( 386 388 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 387 389 'total_pages' => ceil( $total / $per_page ), -
src/wp-admin/includes/class-wp-comments-list-table.php
198 198 $stati = array( 199 199 'all' => _nx_noop('All', 'All', 'comments'), // singular not used 200 200 'moderated' => _n_noop('Pending <span class="count">(<span class="pending-count">%s</span>)</span>', 'Pending <span class="count">(<span class="pending-count">%s</span>)</span>'), 201 'approved' => _n_noop('Approved ', 'Approved'), // singular not used201 'approved' => _n_noop('Approved <span class="count">(<span class="approved-count">%s</span>)</span>', 'Approved <span class="count">(<span class="approved-count">%s</span>)</span>'), 202 202 'spam' => _n_noop('Spam <span class="count">(<span class="spam-count">%s</span>)</span>', 'Spam <span class="count">(<span class="spam-count">%s</span>)</span>'), 203 203 'trash' => _n_noop('Trash <span class="count">(<span class="trash-count">%s</span>)</span>', 'Trash <span class="count">(<span class="trash-count">%s</span>)</span>') 204 204 ); -
src/wp-admin/js/edit-comments.js
12 12 perPageInput = $('input[name="_per_page"]', '#comments-form'); 13 13 pageInput = $('input[name="_page"]', '#comments-form'); 14 14 15 // this fires when viewing "All" 15 16 dimAfter = function( r, settings ) { 16 17 var editRow, replyID, replyButton, 17 18 c = $( '#' + settings.element ); … … 34 35 35 36 diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; 36 37 updatePending( diff ); 38 updateCountText( 'span.approved-count', -1 * diff ); 37 39 }; 38 40 39 41 // Send current total, page, per_page and url … … 137 139 }); 138 140 }; 139 141 142 updateCountText = function( selector, diff ) { 143 $( selector ).each(function() { 144 var a = $(this), n = getCount(a) + diff; 145 if ( n < 1 ) 146 n = 0; 147 updateCount( a, n ); 148 }); 149 }; 150 140 151 // In admin-ajax.php, we send back the unix time stamp instead of 1 on success 141 152 delAfter = function( r, settings ) { 142 var total_items_i18n, total, spam, trash, pending, 143 untrash = $(settings.target).parent().is('span.untrash'), 144 unspam = $(settings.target).parent().is('span.unspam'), 145 unapproved = $('#' + settings.element).is('.unapproved'); 153 var total_items_i18n, total, 154 response = settings.parsed.responses ? settings.parsed.responses[0] : {}, 155 commentStatus = response.data, 146 156 147 function getUpdate(s) { 148 if ( $(settings.target).parent().is('span.' + s) ) 149 return 1; 150 else if ( $('#' + settings.element).is('.' + s) ) 151 return -1; 157 targetParent = $(settings.target).parent(), 158 commentRow = $('#' + settings.element), 152 159 153 return 0; 154 } 160 spamDiff, trashDiff, pendingDiff, approvedDiff, 155 161 156 if ( untrash ) 157 trash = -1; 158 else 159 trash = getUpdate('trash'); 162 approved = commentRow.is('.approved'), 163 unapproved = commentRow.is('.unapproved'); 160 164 161 if ( unspam ) 162 spam = -1; 163 else 164 spam = getUpdate('spam'); 165 // the order of these checks is important 166 // .unspam can also have .approve or .unapprove 167 // .untrash can also have .approve or .unapprove 168 if ( targetParent.is( 'span.spam' ) ) { 169 if ( approved ) { 170 approvedDiff = -1; 171 } else if ( unapproved ) { 172 pendingDiff = -1; 173 } else if ( 'trash' === commentStatus ) { 174 trashDiff = -1; 175 } 176 spamDiff = 1; 177 } else if ( targetParent.is( 'span.unspam' ) ) { 178 if ( '0' === commentStatus ) { 179 pendingDiff = 1; 180 } else if ( '1' === commentStatus ) { 181 approvedDiff = 1; 182 } else if ( 'trash' === commentStatus ) { 183 trashDiff = 1; 184 } 185 spamDiff = -1; 186 } else if ( targetParent.is( 'span.trash' ) ) { 187 if ( approved ) { 188 approvedDiff = -1; 189 } else if ( unapproved ) { 190 pendingDiff = -1; 191 } else if ( 'spam' === commentStatus ) { 192 spamDiff = -1; 193 } 194 trashDiff = 1; 195 } else if ( targetParent.is( 'span.untrash' ) ) { 196 if ( '0' === commentStatus ) { 197 pendingDiff = 1; 198 } else if ( '1' === commentStatus ) { 199 approvedDiff = 1; 200 } else if ( 'spam' === commentStatus ) { 201 spamDiff = 1; 202 } 203 trashDiff = -1; 204 } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { 205 approvedDiff = 1; 206 pendingDiff = -1; 207 } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { 208 approvedDiff = -1; 209 pendingDiff = 1; 210 } 165 211 166 if ( $(settings.target).parent().is('span.unapprove') || ( ( untrash || unspam ) && unapproved ) ) { 167 // a comment was 'deleted' from another list (e.g. approved, spam, trash) and moved to pending, 168 // or a trash/spam of a pending comment was undone 169 pending = 1; 170 } else if ( unapproved ) { 171 // a pending comment was trashed/spammed/approved 172 pending = -1; 212 if ( pendingDiff ) { 213 updatePending( pendingDiff ); 173 214 } 174 215 175 if ( pending ) 176 updatePending(pending); 216 if ( approvedDiff ) { 217 updateCountText( 'span.approved-count', approvedDiff ); 218 } 177 219 178 $('span.spam-count').each( function() { 179 var a = $(this), n = getCount(a) + spam; 180 updateCount(a, n); 181 }); 220 if ( spamDiff ) { 221 updateCountText( 'span.spam-count', spamDiff ); 222 } 182 223 183 $('span.trash-count').each( function() { 184 var a = $(this), n = getCount(a) + trash; 185 updateCount(a, n); 186 }); 224 if ( trashDiff ) { 225 updateCountText( 'span.trash-count', trashDiff ); 226 } 187 227 188 228 if ( ! $('#dashboard_right_now').length ) { 189 229 total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0; … … 195 235 if ( total < 0 ) 196 236 total = 0; 197 237 198 if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {199 total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || '';238 if ( ( 'object' === typeof r ) && lastConfidentTime < response.supplemental.time ) { 239 total_items_i18n = response.supplemental.total_items_i18n || ''; 200 240 if ( total_items_i18n ) { 201 241 $('.displaying-num').text( total_items_i18n ); 202 $('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n );203 $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', settings.parsed.responses[0].supplemental.total_pages == $('.current-page').val());242 $('.total-pages').text( response.supplemental.total_pages_i18n ); 243 $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val()); 204 244 } 205 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );245 updateTotalCount( total, response.supplemental.time, true ); 206 246 } else { 207 247 updateTotalCount( total, r, false ); 208 248 } 209 249 } 210 250 211 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 || untrash || unspam) {251 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) { 212 252 return; 213 253 } 214 254