Ticket #46346: integer-page-counts.patch
File integer-page-counts.patch, 14.3 KB (added by , 4 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
520 520 $time = time(); 521 521 $comment = get_comment( $comment_id ); 522 522 $counts = wp_count_comments(); 523 $total_pages = wp_total_pages( $total, $per_page ); 523 524 524 525 $x = new WP_Ajax_Response( 525 526 array( … … 530 531 'postId' => $comment ? $comment->comment_post_ID : '', 531 532 /* translators: %s: Number of comments. */ 532 533 'total_items_i18n' => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ), 533 'total_pages' => ceil( $total / $per_page ),534 'total_pages_i18n' => number_format_i18n( ceil( $total / $per_page )),534 'total_pages' => $total_pages, 535 'total_pages_i18n' => number_format_i18n( $total_pages ), 535 536 'total' => $total, 536 537 'time' => $time, 537 538 'in_moderation' => $counts->moderated, -
wp-admin/includes/class-wp-list-table.php
284 284 ); 285 285 286 286 if ( ! $args['total_pages'] && $args['per_page'] > 0 ) { 287 $args['total_pages'] = ceil( $args['total_items'] /$args['per_page'] );287 $args['total_pages'] = wp_total_pages( $args['total_items'], $args['per_page'] ); 288 288 } 289 289 290 290 // Redirect if page number is invalid and headers are not already sent. -
wp-admin/includes/deprecated.php
597 597 $args['role'] = urlencode($this->role); 598 598 599 599 $this->paging_text = paginate_links( array( 600 'total' => ceil($this->total_users_for_query / $this->users_per_page),600 'total' => wp_total_pages( $this->total_users_for_query, $this->users_per_page ), 601 601 'current' => $this->page, 602 602 'base' => 'users.php?%_%', 603 603 'format' => 'userspage=%#%', -
wp-admin/includes/media.php
2807 2807 'format' => '', 2808 2808 'prev_text' => __( '«' ), 2809 2809 'next_text' => __( '»' ), 2810 'total' => ceil( $wp_query->found_posts /10 ),2810 'total' => wp_total_pages( $wp_query->found_posts, 10 ), 2811 2811 'current' => $q['paged'], 2812 2812 ) 2813 2813 ); -
wp-admin/includes/nav-menu.php
723 723 return; 724 724 } 725 725 726 $num_pages = ceil(726 $num_pages = wp_total_pages( 727 727 wp_count_terms( 728 728 array_merge( 729 729 $args, … … 732 732 'offset' => '', 733 733 ) 734 734 ) 735 ) /$per_page735 ), $per_page 736 736 ); 737 737 738 738 $page_links = paginate_links( -
wp-admin/widgets.php
514 514 $sidebars_count = count( $theme_sidebars ); 515 515 516 516 if ( $sidebars_count > 1 ) { 517 $split = (int) ceil( $sidebars_count /2 );517 $split = wp_total_pages( $sidebars_count, 2 ); 518 518 } else { 519 519 $single_sidebar_class = ' single-sidebar'; 520 520 } -
wp-includes/class-wp-comment-query.php
451 451 } 452 452 453 453 if ( $this->found_comments && $this->query_vars['number'] ) { 454 $this->max_num_pages = ceil( $this->found_comments /$this->query_vars['number'] );454 $this->max_num_pages = wp_total_pages( $this->found_comments, $this->query_vars['number'] ); 455 455 } 456 456 457 457 // If querying for a count only, there's nothing more to do. -
wp-includes/class-wp-network-query.php
268 268 } 269 269 270 270 if ( $this->found_networks && $this->query_vars['number'] ) { 271 $this->max_num_pages = ceil( $this->found_networks /$this->query_vars['number'] );271 $this->max_num_pages = wp_total_pages( $this->found_networks, $this->query_vars['number'] ); 272 272 } 273 273 274 274 // If querying for a count only, there's nothing more to do. -
wp-includes/class-wp-query.php
3281 3281 $this->found_posts = (int) apply_filters_ref_array( 'found_posts', array( $this->found_posts, &$this ) ); 3282 3282 3283 3283 if ( ! empty( $limits ) ) { 3284 $this->max_num_pages = ceil( $this->found_posts /$q['posts_per_page'] );3284 $this->max_num_pages = wp_total_pages( $this->found_posts, $q['posts_per_page'] ); 3285 3285 } 3286 3286 } 3287 3287 -
wp-includes/class-wp-site-query.php
359 359 } 360 360 361 361 if ( $this->found_sites && $this->query_vars['number'] ) { 362 $this->max_num_pages = ceil( $this->found_sites /$this->query_vars['number'] );362 $this->max_num_pages = wp_total_pages( $this->found_sites, $this->query_vars['number'] ); 363 363 } 364 364 365 365 // If querying for a count only, there's nothing more to do. -
wp-includes/class-wp-walker.php
307 307 $start = ( (int) $page_num - 1 ) * (int) $per_page; 308 308 $end = $start + $per_page; 309 309 if ( -1 == $max_depth ) { 310 $this->max_pages = ceil( $total_top /$per_page );310 $this->max_pages = wp_total_pages( $total_top, (int) $per_page ); 311 311 } 312 312 } 313 313 … … 351 351 352 352 $total_top = count( $top_level_elements ); 353 353 if ( $paging ) { 354 $this->max_pages = ceil( $total_top /$per_page );354 $this->max_pages = wp_total_pages( $total_top, (int) $per_page ); 355 355 } else { 356 356 $end = $total_top; 357 357 } -
wp-includes/comment-template.php
1454 1454 1455 1455 $top_level_count = $top_level_query->query( $top_level_args ); 1456 1456 1457 $comment_args['offset'] = ( ceil( $top_level_count /$per_page ) - 1 ) * $per_page;1457 $comment_args['offset'] = ( wp_total_pages( $top_level_count, $per_page ) - 1 ) * $per_page; 1458 1458 } 1459 1459 } 1460 1460 -
wp-includes/comment.php
1046 1046 1047 1047 if ( $threaded ) { 1048 1048 $walker = new Walker_Comment; 1049 $count = ceil( $walker->get_number_of_root_elements( $comments ) /$per_page );1049 $count = wp_total_pages( $walker->get_number_of_root_elements( $comments ), $per_page ); 1050 1050 } else { 1051 $count = ceil( count( $comments ) /$per_page );1051 $count = wp_total_pages( count( $comments ), $per_page ); 1052 1052 } 1053 1053 1054 1054 return $count; … … 1187 1187 if ( 0 == $older_comment_count ) { 1188 1188 $page = 1; 1189 1189 1190 // Divide comments older than this one by comments per page to get this comment's page number.1190 // Use this comment's chronological position to determine its page number. 1191 1191 } else { 1192 $page = ceil( ( $older_comment_count + 1 ) /$args['per_page'] );1192 $page = wp_total_pages( $older_comment_count + 1, $args['per_page'] ); 1193 1193 } 1194 1194 } 1195 1195 -
wp-includes/functions.php
7866 7866 function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) { 7867 7867 return abs( (float) $expected - (float) $actual ) <= $precision; 7868 7868 } 7869 7870 /** 7871 * Calculate the number of pages a set of results can be split into. 7872 * 7873 * This is similar to using `ceil()` on division but returns an integer. 7874 * 7875 * @since 5.8.0 7876 * 7877 * @param int $total_items The count of items to paginate. 7878 * @param int $per_page The maximum number of items per page. 7879 * @return int The total number of pages. 7880 */ 7881 function wp_total_pages( $total_items, $per_page ) { 7882 $remainder = $total_items % $per_page; 7883 if ( $remainder ) { 7884 $total_items += $per_page - $remainder; 7885 } 7886 return $total_items / $per_page; 7887 } -
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
297 297 $prepared_args['count'] = true; 298 298 299 299 $total_comments = $query->query( $prepared_args ); 300 $max_pages = ceil( $total_comments /$request['per_page'] );300 $max_pages = wp_total_pages( $total_comments, $request['per_page'] ); 301 301 } 302 302 303 303 $response = rest_ensure_response( $comments ); -
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
345 345 $total_posts = $count_query->found_posts; 346 346 } 347 347 348 $max_pages = ceil( $total_posts /(int) $posts_query->query_vars['posts_per_page'] );348 $max_pages = wp_total_pages( (int) $total_posts, (int) $posts_query->query_vars['posts_per_page'] ); 349 349 350 350 if ( $page > $max_pages && $total_posts > 0 ) { 351 351 return new WP_Error( -
wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.php
294 294 } 295 295 296 296 if ( $revisions_query->query_vars['posts_per_page'] > 0 ) { 297 $max_pages = ceil( $total_revisions /(int) $revisions_query->query_vars['posts_per_page'] );297 $max_pages = wp_total_pages( (int) $total_revisions, (int) $revisions_query->query_vars['posts_per_page'] ); 298 298 } else { 299 299 $max_pages = $total_revisions > 0 ? 1 : 0; 300 300 } -
wp-includes/rest-api/endpoints/class-wp-rest-search-controller.php
152 152 $total = (int) $result[ WP_REST_Search_Handler::RESULT_TOTAL ]; 153 153 $page = (int) $request['page']; 154 154 $per_page = (int) $request['per_page']; 155 $max_pages = ceil( $total /$per_page );155 $max_pages = wp_total_pages( $total, $per_page ); 156 156 157 157 if ( $page > $max_pages && $total > 0 ) { 158 158 return new WP_Error( -
wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php
281 281 282 282 // Store pagination values for headers. 283 283 $per_page = (int) $prepared_args['number']; 284 $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 );284 $page = wp_total_pages( (int) $prepared_args['offset'], $per_page ) + 1; 285 285 286 286 $response->header( 'X-WP-Total', (int) $total_terms ); 287 287 288 $max_pages = ceil( $total_terms /$per_page );288 $max_pages = wp_total_pages( (int) $total_terms, $per_page ); 289 289 290 290 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 291 291 -
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
329 329 330 330 // Store pagination values for headers then unset for count query. 331 331 $per_page = (int) $prepared_args['number']; 332 $page = ceil( ( ( (int) $prepared_args['offset'] ) / $per_page ) + 1 );332 $page = wp_total_pages( (int) $prepared_args['offset'], $per_page ) + 1; 333 333 334 334 $prepared_args['fields'] = 'ID'; 335 335 … … 344 344 345 345 $response->header( 'X-WP-Total', (int) $total_users ); 346 346 347 $max_pages = ceil( $total_users /$per_page );347 $max_pages = wp_total_pages( (int) $total_users, $per_page ); 348 348 349 349 $response->header( 'X-WP-TotalPages', (int) $max_pages ); 350 350 -
wp-includes/sitemaps/providers/class-wp-sitemaps-taxonomies.php
158 158 159 159 $term_count = wp_count_terms( $this->get_taxonomies_query_args( $taxonomy ) ); 160 160 161 return (int) ceil( $term_count /wp_sitemaps_get_max_urls( $this->object_type ) );161 return wp_total_pages( $term_count, wp_sitemaps_get_max_urls( $this->object_type ) ); 162 162 } 163 163 164 164 /** -
wp-includes/sitemaps/providers/class-wp-sitemaps-users.php
119 119 120 120 $total_users = $query->get_total(); 121 121 122 return (int) ceil( $total_users /wp_sitemaps_get_max_urls( $this->object_type ) );122 return wp_total_pages( $total_users, wp_sitemaps_get_max_urls( $this->object_type ) ); 123 123 } 124 124 125 125 /**