Ticket #11200: 11200.3.diff
File 11200.3.diff, 12.4 KB (added by , 9 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
347 347 $url = isset( $_POST['_url'] ) ? esc_url_raw( $_POST['_url'] ) : ''; 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 ); 352 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 } 365 353 366 $total += $delta; 354 367 if ( $total < 0 ) 355 368 $total = 0; … … 377 390 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( 382 396 'what' => 'comment', … … 383 397 // Here for completeness - not used. 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 ), 388 403 'total_pages_i18n' => number_format_i18n( 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 = true === settings.parsed ? {} : settings.parsed.responses[0], 155 commentStatus = true === settings.parsed ? '' : response.supplemental.status, 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 else159 trash = getUpdate('trash');162 approved = commentRow.hasClass( 'approved' ), 163 unapproved = commentRow.hasClass( 'unapproved' ), 164 spammed = commentRow.hasClass( 'spam' ), 165 trashed = commentRow.hasClass( 'trash' ); 160 166 161 if ( unspam ) 162 spam = -1; 163 else 164 spam = getUpdate('spam'); 167 // the order of these checks is important 168 // .unspam can also have .approve or .unapprove 169 // .untrash can also have .approve or .unapprove 165 170 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; 171 if ( targetParent.is( 'span.undo' ) ) { 172 // the comment was spammed 173 if ( targetParent.hasClass( 'unspam' ) ) { 174 spamDiff = -1; 175 176 if ( 'trash' === commentStatus ) { 177 trashDiff = 1; 178 } else if ( '1' === commentStatus ) { 179 approvedDiff = 1; 180 } else if ( '0' === commentStatus ) { 181 pendingDiff = 1; 182 } 183 184 // the comment was trashed 185 } else if ( targetParent.hasClass( 'untrash' ) ) { 186 trashDiff = -1; 187 188 if ( 'spam' === commentStatus ) { 189 spamDiff = 1; 190 } else if ( '1' === commentStatus ) { 191 approvedDiff = 1; 192 } else if ( '0' === commentStatus ) { 193 pendingDiff = 1; 194 } 195 } 196 197 // user clicked "Spam" 198 } else if ( targetParent.is( 'span.spam' ) ) { 199 // the comment is currently approved 200 if ( approved ) { 201 approvedDiff = -1; 202 // the comment is currently pending 203 } else if ( unapproved ) { 204 pendingDiff = -1; 205 // the comment was in the trash 206 } else if ( trashed ) { 207 trashDiff = -1; 208 } 209 // you can't spam an item on the spam screen 210 spamDiff = 1; 211 212 // user clicked "Unspam" 213 } else if ( targetParent.is( 'span.unspam' ) ) { 214 if ( approved ) { 215 pendingDiff = 1; 216 } else if ( unapproved ) { 217 approvedDiff = 1; 218 } else if ( trashed ) { 219 // the comment was previously approved 220 if ( targetParent.hasClass( 'approve' ) ) { 221 approvedDiff = 1; 222 // the comment was previously pending 223 } else if ( targetParent.hasClass( 'unapprove' ) ) { 224 pendingDiff = 1; 225 } 226 } else if ( spammed ) { 227 if ( targetParent.hasClass( 'approve' ) ) { 228 approvedDiff = 1; 229 230 } else if ( targetParent.hasClass( 'unapprove' ) ) { 231 pendingDiff = 1; 232 } 233 } 234 // you can Unspam an item on the spam screen 235 spamDiff = -1; 236 237 // user clicked "Trash" 238 } else if ( targetParent.is( 'span.trash' ) ) { 239 if ( approved ) { 240 approvedDiff = -1; 241 } else if ( unapproved ) { 242 pendingDiff = -1; 243 // the comment was in the spam queue 244 } else if ( spammed ) { 245 spamDiff = -1; 246 } 247 // you can't trash an item on the trash screen 248 trashDiff = 1; 249 250 // user clicked "Restore" 251 } else if ( targetParent.is( 'span.untrash' ) ) { 252 if ( approved ) { 253 pendingDiff = 1; 254 } else if ( unapproved ) { 255 approvedDiff = 1; 256 } else if ( trashed ) { 257 if ( targetParent.hasClass( 'approve' ) ) { 258 approvedDiff = 1; 259 } else if ( targetParent.hasClass( 'unapprove' ) ) { 260 pendingDiff = 1; 261 } 262 } 263 // you can't go from trash to spam 264 // you can untrash on the trash screen 265 trashDiff = -1; 266 267 // User clicked "Approve" 268 } else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { 269 approvedDiff = 1; 270 pendingDiff = -1; 271 272 // User clicked "Unapprove" 273 } else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { 274 approvedDiff = -1; 275 pendingDiff = 1; 276 277 } else if ( targetParent.is( 'span.delete' ) ) { 278 if ( spammed ) { 279 spamDiff = -1; 280 } else if ( trashed ) { 281 trashDiff = -1; 282 } 173 283 } 174 284 175 if ( pending ) 176 updatePending(pending); 285 if ( pendingDiff ) { 286 updatePending( pendingDiff ); 287 } 177 288 178 $('span.spam-count').each( function() { 179 var a = $(this), n = getCount(a) + spam; 180 updateCount(a, n); 181 }); 289 if ( approvedDiff ) { 290 updateCountText( 'span.approved-count', approvedDiff ); 291 } 182 292 183 $('span.trash-count').each( function() { 184 var a = $(this), n = getCount(a) + trash; 185 updateCount(a, n); 186 }); 293 if ( spamDiff ) { 294 updateCountText( 'span.spam-count', spamDiff ); 295 } 187 296 297 if ( trashDiff ) { 298 updateCountText( 'span.trash-count', trashDiff ); 299 } 300 188 301 if ( ! $('#dashboard_right_now').length ) { 189 302 total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0; 190 303 if ( $(settings.target).parent().is('span.undo') ) … … 195 308 if ( total < 0 ) 196 309 total = 0; 197 310 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()); 311 if ( 'object' === typeof r ) { 312 if ( response.supplemental.total_items_i18n && lastConfidentTime < response.supplemental.time ) { 313 total_items_i18n = response.supplemental.total_items_i18n || ''; 314 if ( total_items_i18n ) { 315 $('.displaying-num').text( total_items_i18n ); 316 $('.total-pages').text( response.supplemental.total_pages_i18n ); 317 $('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val()); 318 } 319 updateTotalCount( total, response.supplemental.time, true ); 320 } else if ( response.supplemental.time ) { 321 updateTotalCount( total, response.supplemental.time, false ); 204 322 } 205 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );206 323 } else { 207 324 updateTotalCount( total, r, false ); 208 325 } 209 326 } 210 327 211 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 || untrash || unspam) {328 if ( ! theExtraList || theExtraList.size() === 0 || theExtraList.children().size() === 0 ) { 212 329 return; 213 330 } 214 331 -
src/wp-includes/comment.php
1857 1857 do_action( 'trash_comment', $comment_id ); 1858 1858 1859 1859 if ( wp_set_comment_status($comment_id, 'trash') ) { 1860 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1861 add_comment_meta($comment_id, '_wp_trash_meta_time', time() ); 1860 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 1861 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); 1862 add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); 1863 add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); 1862 1864 1863 1865 /** 1864 1866 * Fires immediately after a comment is sent to Trash. … … 1938 1940 do_action( 'spam_comment', $comment_id ); 1939 1941 1940 1942 if ( wp_set_comment_status($comment_id, 'spam') ) { 1941 add_comment_meta($comment_id, '_wp_trash_meta_status', $comment->comment_approved); 1943 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 1944 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); 1945 add_comment_meta( $comment_id, '_wp_trash_meta_status', $comment->comment_approved ); 1946 add_comment_meta( $comment_id, '_wp_trash_meta_time', time() ); 1942 1947 /** 1943 1948 * Fires immediately after a comment is marked as Spam. 1944 1949 * … … 1979 1984 $status = '0'; 1980 1985 1981 1986 if ( wp_set_comment_status($comment_id, $status) ) { 1982 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 1987 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 1988 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); 1983 1989 /** 1984 1990 * Fires immediately after a comment is unmarked as Spam. 1985 1991 *