Skip to content

Commit

Permalink
Refactor requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Bravo committed Mar 15, 2022
1 parent 2d6b1f6 commit a5953bc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/compat/experimental/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ function build_comment_query_vars_from_block( $block ) {
} elseif ( 'oldest' === $default_page ) {
$comment_args['paged'] = 1;
} elseif ( 'newest' === $default_page ) {
$comment_args['paged'] = ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
$comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
}
// Set the `cpage` query var to ensure the previous and next pagination links are correct
// when inheriting the Discussion Settings.
if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
set_query_var( 'cpage', $comment_args['paged'] );
}
}
if ( empty($page) && $comment_args['paged'] ) {
set_query_var( 'cpage', $comment_args['paged'] );
}

return $comment_args;
Expand Down

0 comments on commit a5953bc

Please sign in to comment.