Ticket #15530: 15530.2.diff
| File 15530.2.diff, 8.0 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
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) 202 $total = 0; 201 set_current_screen( 'edit-comments' ); 203 202 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() ); 203 $wp_list_table = _get_list_table('WP_Comments_List_Table'); 206 204 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 } 205 $wp_list_table->prepare_items(); 217 206 218 $comment_count = wp_count_comments($post_id); 219 $time = time(); // The time since the last comment count 207 extract( $wp_list_table->_pagination_args ); 220 208 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 224 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( 209 $response = array( 234 210 'what' => 'comment', 235 211 'id' => $comment_id, // here for completeness - not used 236 212 'supplemental' => array( 237 'pageLinks' => $page_links, 213 'time' => time(), 214 /* 'pageLinks' => $wp_list_table->pagination( 'top', false ), 215 'pageLinksBottom' => $wp_list_table->pagination( 'bottom', false ), 216 'l10nTotal' => sprintf( _n( '1 item', '%s items', $total ), number_format_i18n( $total ) ), 238 217 'total' => $total, 239 'time' => $time 240 ) 241 ) ); 218 */ ), 219 ); 220 221 if ( isset( $total_items ) ) { 222 $response['supplemental']['total_items'] = $total_items; 223 $response['supplemental']['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ); 224 } 225 226 if ( isset( $total_pages ) ) { 227 $response['supplemental']['total_pages'] = $total_pages; 228 $response['supplemental']['total_pages_i18n'] = number_format_i18n( $total_pages ); 229 } 230 231 // TODO: determine if pagination links need to be updated in case total number of pages change 232 233 $x = new WP_Ajax_Response( $response ); 234 242 235 $x->send(); 243 236 } 244 237 -
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 92 93 if ( setConfidentTime ) 93 94 lastConfidentTime = time; 94 95 95 totalInput.val( total.toString() ); 96 $('span.total-type-count').each( function() { 97 updateCount( $(this), total ); 98 }); 96 totalInput.val( total ); 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 var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash ;142 var total, pageLinks, N, untrash = $(settings.target).parent().is('span.untrash'), unspam = $(settings.target).parent().is('span.unspam'), spam, trash, parsedResponse, tablenav; 144 143 145 144 function getUpdate(s) { 146 145 if ( $(settings.target).parent().is('span.' + s) ) … … 191 190 if ( total < 0 ) 192 191 total = 0; 193 192 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 else 199 $('.tablenav-pages').find( '.page-numbers' ).remove(); 200 201 updateTotalCount( total, settings.parsed.responses[0].supplemental.time, true ); 202 } else { 203 updateTotalCount( total, r, false ); 193 if ( ( 'object' == typeof r ) && lastConfidentTime < settings.parsed.responses[0].supplemental.time ) { 194 parsedResponse = settings.parsed.responses[0].supplemental; 195 tablenav = $('.tablenav-pages'); 196 $('.displaying-num').html(parsedResponse.total_items_i18n); 197 $('.total-pages').html(parsedResponse.total_pages_i18n); 198 if ( parsedResponse.total_pages > 1 ) 199 tablenav.removeClass('one-page'); 200 updateTotalCount( parsedResponse.total_items, parsedResponse.time, true, parsedResponse.total_items_i18n ); 201 tablenav.find('.first-page, .prev-page').toggleClass('disabled', 1 == $('.current-page').val()); 202 tablenav.find('.next-page, .last-page').toggleClass('disabled', parsedResponse.total_pages == $('.current-page').val()); 203 // update last page href: tablenav.find('.last-page.').attr('href').val( $.query.SET('paged', parsedResponse.total_pages ) ); 204 204 } 205 205 } 206 206 207 208 207 if ( ! theExtraList || theExtraList.size() == 0 || theExtraList.children().size() == 0 || untrash || unspam ) { 209 208 return; 210 209 }