Ticket #15530: 15530.diff
| File 15530.diff, 9.2 KB (added by , 15 years ago) |
|---|
-
wp-admin/edit-comments.php
228 228 <input type="hidden" name="comment_status" value="<?php echo esc_attr($comment_status); ?>" /> 229 229 <input type="hidden" name="pagegen_timestamp" value="<?php echo esc_attr(current_time('mysql', 1)); ?>" /> 230 230 231 <input type="hidden" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" />232 <input type="hidden" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" />233 <input type="hidden" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" />231 <input type="hidden" autocomplete="off" name="_total" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('total_items') ); ?>" /> 232 <input type="hidden" autocomplete="off" name="_per_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('per_page') ); ?>" /> 233 <input type="hidden" autocomplete="off" name="_page" value="<?php echo esc_attr( $wp_list_table->get_pagination_arg('page') ); ?>" /> 234 234 235 235 <?php if ( isset($_REQUEST['paged']) ) { ?> 236 236 <input type="hidden" name="paged" value="<?php echo esc_attr( absint( $_REQUEST['paged'] ) ); ?>" /> -
wp-admin/admin-ajax.php
189 189 * @param int $comment_id 190 190 * @return die 191 191 */ 192 function _wp_ajax_delete_comment_response( $comment_id ) {192 function _wp_ajax_delete_comment_response( $comment_id, $delta = -1 ) { 193 193 $total = (int) @$_POST['_total']; 194 194 $per_page = (int) @$_POST['_per_page']; 195 195 $page = (int) @$_POST['_page']; … … 198 198 if ( !$total || !$per_page || !$page || !$url ) 199 199 die( (string) time() ); 200 200 201 if ( --$total < 0 ) // Take the total from POST and decrement it (since we just deleted one) 201 $total += $delta; 202 if ( $total < 0 ) 202 203 $total = 0; 203 204 204 if ( 0 != $total % $per_page && 1 != mt_rand( 1, $per_page ) ) // Only do the expensive stuff on a page-break, and about 1 other time per page 205 die( (string) time() ); 205 set_current_screen( 'edit-comments' ); 206 206 207 $post_id = 0; 208 $status = 'total_comments'; // What type of comment count are we looking for? 209 $parsed = parse_url( $url ); 210 if ( isset( $parsed['query'] ) ) { 211 parse_str( $parsed['query'], $query_vars ); 212 if ( !empty( $query_vars['comment_status'] ) ) 213 $status = $query_vars['comment_status']; 214 if ( !empty( $query_vars['p'] ) ) 215 $post_id = (int) $query_vars['p']; 216 } 207 $wp_list_table = _get_list_table('WP_Comments_List_Table'); 217 208 218 $comment_count = wp_count_comments($post_id); 219 $time = time(); // The time since the last comment count 209 $wp_list_table->prepare_items(); 220 210 221 if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count 222 $total = $comment_count->$status; 223 // else use the decremented value from above 211 error_log( $wp_list_table->pagination( 'top', false ) ); 224 212 225 $page_links = paginate_links( array( 226 'base' => add_query_arg( 'apage', '%#%', $url ), 227 'format' => '', 228 'prev_text' => __('«'), 229 'next_text' => __('»'), 230 'total' => ceil($total / $per_page), 231 'current' => $page 232 ) ); 233 $x = new WP_Ajax_Response( array( 213 $response = array( 234 214 'what' => 'comment', 235 215 'id' => $comment_id, // here for completeness - not used 236 216 'supplemental' => array( 237 'pageLinks' => $page_links, 217 'time' => time(), 218 'pageLinks' => $wp_list_table->pagination( 'top', false ), 219 'pageLinksBottom' => $wp_list_table->pagination( 'bottom', false ), 220 'l10nTotal' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ), 238 221 'total' => $total, 239 'time' => $time 240 ) 241 ) ); 222 ), 223 ); 224 225 // TODO: determine if pagination links need to be updated in case total number of pages change 226 227 $x = new WP_Ajax_Response( $response ); 228 242 229 $x->send(); 243 230 } 244 231 … … 330 317 331 318 check_ajax_referer( "delete-comment_$id" ); 332 319 $status = wp_get_comment_status( $comment->comment_ID ); 333 320 321 $delta = -1; 334 322 if ( isset($_POST['trash']) && 1 == $_POST['trash'] ) { 335 323 if ( 'trash' == $status ) 336 324 die( (string) time() ); … … 339 327 if ( 'trash' != $status ) 340 328 die( (string) time() ); 341 329 $r = wp_untrash_comment( $comment->comment_ID ); 330 if ( $_POST['comment_status'] != 'trash' ) //undo trash 331 $delta = 1; 342 332 } elseif ( isset($_POST['spam']) && 1 == $_POST['spam'] ) { 343 333 if ( 'spam' == $status ) 344 334 die( (string) time() ); … … 347 337 if ( 'spam' != $status ) 348 338 die( (string) time() ); 349 339 $r = wp_unspam_comment( $comment->comment_ID ); 340 if ( $_POST['comment_status'] != 'spam' ) // undo spam 341 $delta = 1; 350 342 } elseif ( isset($_POST['delete']) && 1 == $_POST['delete'] ) { 351 343 $r = wp_delete_comment( $comment->comment_ID ); 352 344 } else { … … 354 346 } 355 347 356 348 if ( $r ) // Decide if we need to send back '1' or a more complicated response including page links and comment counts 357 _wp_ajax_delete_comment_response( $comment->comment_ID );349 _wp_ajax_delete_comment_response( $comment->comment_ID, $delta ); 358 350 die( '0' ); 359 351 break; 360 352 case 'delete-tag' : -
wp-admin/includes/class-wp-list-table.php
467 467 * @since 3.1.0 468 468 * @access protected 469 469 */ 470 function pagination( $which ) {470 function pagination( $which, $echo = true ) { 471 471 if ( empty( $this->_pagination_args ) ) 472 472 return; 473 473 … … 534 534 535 535 $this->_pagination = "<div class='tablenav-pages{$page_class}'>$output</div>"; 536 536 537 echo $this->_pagination; 537 if ( $echo ) 538 echo $this->_pagination; 539 else 540 return $this->_pagination; 538 541 } 539 542 540 543 /** -
wp-admin/js/edit-comments.dev.js
4 4 setCommentsList = function() { 5 5 var totalInput, perPageInput, pageInput, lastConfidentTime = 0, dimAfter, delBefore, updateTotalCount, delAfter; 6 6 7 totalInput = $(' .tablenavinput[name="_total"]', '#comments-form');8 perPageInput = $(' .tablenavinput[name="_per_page"]', '#comments-form');9 pageInput = $(' .tablenavinput[name="_page"]', '#comments-form');7 totalInput = $('input[name="_total"]', '#comments-form'); 8 perPageInput = $('input[name="_per_page"]', '#comments-form'); 9 pageInput = $('input[name="_page"]', '#comments-form'); 10 10 11 11 dimAfter = function( r, settings ) { 12 12 var c = $('#' + settings.element); … … 38 38 settings.data._per_page = perPageInput.val() || 0; 39 39 settings.data._page = pageInput.val() || 0; 40 40 settings.data._url = document.location.href; 41 settings.data.comment_status = $('input[name=comment_status]', '#comments-form').val(); 41 42 42 43 if ( cl.indexOf(':trash=1') != -1 ) 43 44 action = 'trash'; … … 85 86 }; 86 87 87 88 // Updates the current total (as displayed visibly) 88 updateTotalCount = function( total, time, setConfidentTime ) {89 updateTotalCount = function( total, time, setConfidentTime, l10nTotal ) { 89 90 if ( time < lastConfidentTime ) 90 91 return; 91 92 … … 93 94 lastConfidentTime = time; 94 95 95 96 totalInput.val( total.toString() ); 96 $('span.total-type-count').each( function() { 97 updateCount( $(this), total ); 98 }); 97 $('span.displaying-num').text(l10nTotal); 99 98 }; 100 99 101 100 function dashboardTotals(n) { … … 138 137 el.html(n); 139 138 } 140 139 141 // In admin-ajax.php, we send back the unix time stamp instead of 1on success140 // In admin-ajax.php, we send back the unix time stamp as well as localized total items on success 142 141 delAfter = function( r, settings ) { 143 142 var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash; 144 143 … … 191 190 if ( total < 0 ) 192 191 total = 0; 193 192 194 if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {193 if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { 195 194 pageLinks = settings.parsed.responses[0].supplemental.pageLinks || ''; 196 if ( $.trim( pageLinks ) ) 197 $('.t ablenav-pages').find( '.page-numbers' ).remove().end().append( $( pageLinks ));198 else199 $('.tablenav-pages').find( '.page-numbers' ).remove();200 201 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true );202 } else {203 updateTotalCount( total, r, false );195 if ( $.trim( pageLinks ) ) { 196 $('.top .tablenav-pages').html( pageLinks ); 197 $('.bottom .tablenav-pages').html( settings.parsed.responses[0].supplemental.pageLinksBottom ); 198 } else { 199 $('.tablenav-pages').remove(); 200 } 201 parsedResponse = settings.parsed.responses[0]; 202 updateTotalCount( parsedResponse.supplemental.total, parsedResponse.supplemental.time, true, parsedResponse.supplemental.l10nTotal ); 204 203 } 205 204 } 206 205 207 208 206 if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) { 209 207 return; 210 208 }