Ticket #15530: 15530.4.diff
| File 15530.4.diff, 4.4 KB (added by , 15 years ago) |
|---|
-
wp-admin/admin-ajax.php
201 201 if ( --$total < 0 ) // Take the total from POST and decrement it (since we just deleted one) 202 202 $total = 0; 203 203 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() ); 204 // Only do the expensive stuff on a page-break, and about 1 other time per page 205 if ( 0 == $total % $per_page || 1 == mt_rand( 1, $per_page ) ) { 206 $post_id = 0; 207 $status = 'total_comments'; // What type of comment count are we looking for? 208 $parsed = parse_url( $url ); 209 if ( isset( $parsed['query'] ) ) { 210 parse_str( $parsed['query'], $query_vars ); 211 if ( !empty( $query_vars['comment_status'] ) ) 212 $status = $query_vars['comment_status']; 213 if ( !empty( $query_vars['p'] ) ) 214 $post_id = (int) $query_vars['p']; 215 } 206 216 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']; 217 $comment_count = wp_count_comments($post_id); 218 219 if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count 220 $total = $comment_count->$status; 221 // else use the decremented value from above 216 222 } 217 223 218 $comment_count = wp_count_comments($post_id);219 224 $time = time(); // The time since the last comment count 220 225 221 if ( isset( $comment_count->$status ) ) // We're looking for a known type of comment count222 $total = $comment_count->$status;223 // else use the decremented value from above224 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' => $page232 ) );233 226 $x = new WP_Ajax_Response( array( 234 227 'what' => 'comment', 235 228 'id' => $comment_id, // here for completeness - not used 236 229 'supplemental' => array( 237 'pageLinks' => $page_links, 230 'total_items_i18n' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ), 231 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page ) ), 238 232 'total' => $total, 239 233 'time' => $time 240 234 ) -
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); … … 190 190 total = total - spam - trash; 191 191 if ( total < 0 ) 192 192 total = 0; 193 194 if ( ( 'object' == typeof r ) &&lastConfidentTime < settings.parsed.responses[0].supplemental.time ) {195 pageLinks = settings.parsed.responses[0].supplemental.pageLinks|| '';196 if ( $.trim( pageLinks ) )197 $('.tablenav-pages').find( '.page-numbers' ).remove().end().append( $( pageLinks ) );198 else199 $('.t ablenav-pages').find( '.page-numbers' ).remove();200 193 console.log( r ); 194 if ( lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { 195 total_items_i18n = settings.parsed.responses[0].supplemental.total_items_i18n || ''; 196 console.log( total_items_i18n ); 197 if ( total_items_i18n ) { 198 $('.displaying-num').text( total_items_i18n ); 199 $('.total-pages').text( settings.parsed.responses[0].supplemental.total_pages_i18n ); 200 } 201 201 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true ); 202 202 } else { 203 203 updateTotalCount( total, r, false );