Changeset 33655
- Timestamp:
- 08/20/2015 02:50:20 AM (9 years ago)
- Location:
- trunk/src/wp-admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r33468 r33655 348 348 349 349 // JS didn't send us everything we need to know. Just die with success message 350 if ( !$total || !$per_page || !$page || !$url ) 351 wp_die( time() ); 350 if ( ! $total || ! $per_page || ! $page || ! $url ) { 351 $time = time(); 352 $comment = get_comment( $comment_id ); 353 354 $x = new WP_Ajax_Response( array( 355 'what' => 'comment', 356 // Here for completeness - not used. 357 'id' => $comment_id, 358 'supplemental' => array( 359 'status' => $comment ? $comment->comment_approved : '', 360 'time' => $time 361 ) 362 ) ); 363 $x->send(); 364 } 352 365 353 366 $total += $delta; … … 378 391 // The time since the last comment count. 379 392 $time = time(); 393 $comment = get_comment( $comment_id ); 380 394 381 395 $x = new WP_Ajax_Response( array( … … 384 398 'id' => $comment_id, 385 399 'supplemental' => array( 400 'status' => $comment ? $comment->comment_approved : '', 386 401 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 387 402 'total_pages' => ceil( $total / $per_page ), -
trunk/src/wp-admin/includes/class-wp-comments-list-table.php
r33614 r33655 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>') -
trunk/src/wp-admin/js/edit-comments.js
r32857 r33655 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, … … 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 … … 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 } 148 updateCount( a, n ); 149 }); 150 }; 151 140 152 // In admin-ajax.php, we send back the unix time stamp instead of 1 on success 141 153 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'); 146 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; 152 153 return 0; 154 } 155 156 if ( untrash ) 157 trash = -1; 158 else 159 trash = getUpdate('trash'); 160 161 if ( unspam ) 162 spam = -1; 163 else 164 spam = getUpdate('spam'); 165 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; 173 } 174 175 if ( pending ) 176 updatePending(pending); 177 178 $('span.spam-count').each( function() { 179 var a = $(this), n = getCount(a) + spam; 180 updateCount(a, n); 181 }); 182 183 $('span.trash-count').each( function() { 184 var a = $(this), n = getCount(a) + trash; 185 updateCount(a, n); 186 }); 154 var total_items_i18n, total, 155 response = true === settings.parsed ? {} : settings.parsed.responses[0], 156 commentStatus = true === settings.parsed ? '' : response.supplemental.status, 157 158 targetParent = $( settings.target ).parent(), 159 commentRow = $('#' + settings.element), 160 161 spamDiff, trashDiff, pendingDiff, approvedDiff, 162 163 approved = commentRow.hasClass( 'approved' ), 164 unapproved = commentRow.hasClass( 'unapproved' ), 165 spammed = commentRow.hasClass( 'spam' ), 166 trashed = commentRow.hasClass( 'trash' ); 167 168 // the order of these checks is important 169 // .unspam can also have .approve or .unapprove 170 // .untrash can also have .approve or .unapprove 171 172 if ( targetParent.is( 'span.undo' ) ) { 173 // the comment was spammed 174 if ( targetParent.hasClass( 'unspam' ) ) { 175 spamDiff = -1; 176 177 if ( 'trash' === commentStatus ) { 178 trashDiff = 1; 179 } else if ( '1' === commentStatus ) { 180 approvedDiff = 1; 181 } else if ( '0' === commentStatus ) { 182 pendingDiff = 1; 183 } 184 185 // the comment was trashed 186 } else if ( targetParent.hasClass( 'untrash' ) ) { 187 trashDiff = -1; 188 189 if ( 'spam' === commentStatus ) { 190 spamDiff = 1; 191 } else if ( '1' === commentStatus ) { 192 approvedDiff = 1; 193 } else if ( '0' === commentStatus ) { 194 pendingDiff = 1; 195 } 196 } 197 198 // user clicked "Spam" 199 } else if ( targetParent.is( 'span.spam' ) ) { 200 // the comment is currently approved 201 if ( approved ) { 202 approvedDiff = -1; 203 // the comment is currently pending 204 } else if ( unapproved ) { 205 pendingDiff = -1; 206 // the comment was in the trash 207 } else if ( trashed ) { 208 trashDiff = -1; 209 } 210 // you can't spam an item on the spam screen 211 spamDiff = 1; 212 213 // user clicked "Unspam" 214 } else if ( targetParent.is( 'span.unspam' ) ) { 215 if ( approved ) { 216 pendingDiff = 1; 217 } else if ( unapproved ) { 218 approvedDiff = 1; 219 } else if ( trashed ) { 220 // the comment was previously approved 221 if ( targetParent.hasClass( 'approve' ) ) { 222 approvedDiff = 1; 223 // the comment was previously pending 224 } else if ( targetParent.hasClass( 'unapprove' ) ) { 225 pendingDiff = 1; 226 } 227 } else if ( spammed ) { 228 if ( targetParent.hasClass( 'approve' ) ) { 229 approvedDiff = 1; 230 231 } else if ( targetParent.hasClass( 'unapprove' ) ) { 232 pendingDiff = 1; 233 } 234 } 235 // you can Unspam an item on the spam screen 236 spamDiff = -1; 237 238 // user clicked "Trash" 239 } else if ( targetParent.is( 'span.trash' ) ) { 240 if ( approved ) { 241 approvedDiff = -1; 242 } else if ( unapproved ) { 243 pendingDiff = -1; 244 // the comment was in the spam queue 245 } else if ( spammed ) { 246 spamDiff = -1; 247 } 248 // you can't trash an item on the trash screen 249 trashDiff = 1; 250 251 // user clicked "Restore" 252 } else if ( targetParent.is( 'span.untrash' ) ) { 253 if ( approved ) { 254 pendingDiff = 1; 255 } else if ( unapproved ) { 256 approvedDiff = 1; 257 } else if ( trashed ) { 258 if ( targetParent.hasClass( 'approve' ) ) { 259 approvedDiff = 1; 260 } else if ( targetParent.hasClass( 'unapprove' ) ) { 261 pendingDiff = 1; 262 } 263 } 264 // you can't go from trash to spam 265 // you can untrash on the trash screen 266 trashDiff = -1; 267 268 // User clicked "Approve" 269 } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { 270 approvedDiff = 1; 271 pendingDiff = -1; 272 273 // User clicked "Unapprove" 274 } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { 275 approvedDiff = -1; 276 pendingDiff = 1; 277 278 // User clicked "Delete Permanently" 279 } else if ( targetParent.is( 'span.delete' ) ) { 280 if ( spammed ) { 281 spamDiff = -1; 282 } else if ( trashed ) { 283 trashDiff = -1; 284 } 285 } 286 287 if ( pendingDiff ) { 288 updatePending( pendingDiff ); 289 } 290 291 if ( approvedDiff ) { 292 updateCountText( 'span.approved-count', approvedDiff ); 293 } 294 295 if ( spamDiff ) { 296 updateCountText( 'span.spam-count', spamDiff ); 297 } 298 299 if ( trashDiff ) { 300 updateCountText( 'span.trash-count', trashDiff ); 301 } 187 302 188 303 if ( ! $('#dashboard_right_now').length ) { … … 196 311 total = 0; 197 312 198 if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { 199 total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || ''; 200 if ( total_items_i18n ) { 201 $('.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()); 313 if ( 'object' === typeof r ) { 314 if ( response.supplemental.total_items_i18n && lastConfidentTime < response.supplemental.time ) { 315 total_items_i18n = response.supplemental.total_items_i18n || ''; 316 if ( total_items_i18n ) { 317 $('.displaying-num').text( total_items_i18n ); 318 $('.total-pages').text( response.supplemental.total_pages_i18n ); 319 $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val()); 320 } 321 updateTotalCount( total, response.supplemental.time, true ); 322 } else if ( response.supplemental.time ) { 323 updateTotalCount( total, response.supplemental.time, false ); 204 324 } 205 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );206 325 } else { 207 326 updateTotalCount( total, r, false ); … … 209 328 } 210 329 211 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 || untrash || unspam) {330 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) { 212 331 return; 213 332 }
Note: See TracChangeset
for help on using the changeset viewer.