Ticket #50233: 50233.patch
File 50233.patch, 1.6 KB (added by , 4 years ago) |
---|
-
canonical.php
27 27 * or query in an attempt to figure the correct page to go to. 28 28 * 29 29 * @since 2.3.0 30 * 30 * @since 5.6.0 checks comments page count to limit pagination 31 31 * @global WP_Rewrite $wp_rewrite WordPress rewrite component. 32 32 * @global bool $is_IIS 33 33 * @global WP_Query $wp_query WordPress Query object. … … 490 490 && ( 'newest' === $default_comments_page && $cpage > 0 491 491 || 'newest' !== $default_comments_page && $cpage > 1 ) 492 492 ) { 493 $addl_path = ( ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '' ); 494 $addl_path .= user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ); 495 493 //checks comments page count to limit pagination 494 $per_page = get_option( 'comments_per_page' ); 495 $comments_total_pages = ceil( ( $wp_query->post->comment_count ) / $per_page );//get total number of pages for comments 496 if ( $cpage <= $comments_total_pages ) { 497 $addl_path = ( ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '' ); 498 $addl_path .= user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . $cpage, 'commentpaged' ); 499 } 496 500 $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); 497 501 } 498 502 499 503 // Strip off trailing /index.php/. 500 504 $redirect['path'] = preg_replace( '|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path'] ); 501 505 $redirect['path'] = user_trailingslashit( $redirect['path'] );