| 322 | | $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' ); |
| 323 | | $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); |
| | 322 | if ( $wp_query->post ) { |
| | 323 | $top_level_query = new WP_Comment_Query(); |
| | 324 | $top_level_count = $top_level_query->query( array( |
| | 325 | 'count' => true, |
| | 326 | 'orderby' => false, |
| | 327 | 'post_id' => $wp_query->post->ID, |
| | 328 | 'parent' => 0, |
| | 329 | ) ); |
| | 330 | $comments_per_page = get_option( 'comments_per_page' ); |
| | 331 | $total_comment_pages = $comments_per_page ? ceil( $top_level_count / $comments_per_page ) : 1; |
| | 332 | if ( get_query_var('cpage') <= $total_comment_pages ) { |
| | 333 | $addl_path = ( !empty( $addl_path ) ? trailingslashit($addl_path) : '' ) . user_trailingslashit( $wp_rewrite->comments_pagination_base . '-' . get_query_var('cpage'), 'commentpaged' ); |
| | 334 | $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); |
| | 335 | } |
| | 336 | } |