Skip to content

Commit cab6fec

Browse files
committed
Editor: Update build_comment_query_vars_from_block from Gutenberg
Follow-up for [53138]. See #55505. git-svn-id: https://develop.svn.wordpress.org/trunk@53142 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 65e8a87 commit cab6fec

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

src/wp-includes/blocks.php

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,24 +1392,25 @@ function build_comment_query_vars_from_block( $block ) {
13921392
$comment_args['hierarchical'] = false;
13931393
}
13941394

1395-
$per_page = get_option( 'comments_per_page' );
1396-
$default_page = get_option( 'default_comments_page' );
1397-
1398-
if ( $per_page > 0 ) {
1399-
$comment_args['number'] = $per_page;
1400-
1401-
$page = (int) get_query_var( 'cpage' );
1402-
if ( $page ) {
1403-
$comment_args['paged'] = $page;
1404-
} elseif ( 'oldest' === $default_page ) {
1405-
$comment_args['paged'] = 1;
1406-
} elseif ( 'newest' === $default_page ) {
1407-
$comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
1408-
}
1409-
// Set the `cpage` query var to ensure the previous and next pagination links are correct
1410-
// when inheriting the Discussion Settings.
1411-
if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
1412-
set_query_var( 'cpage', $comment_args['paged'] );
1395+
if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) {
1396+
$per_page = get_option( 'comments_per_page' );
1397+
$default_page = get_option( 'default_comments_page' );
1398+
if ( $per_page > 0 ) {
1399+
$comment_args['number'] = $per_page;
1400+
1401+
$page = (int) get_query_var( 'cpage' );
1402+
if ( $page ) {
1403+
$comment_args['paged'] = $page;
1404+
} elseif ( 'oldest' === $default_page ) {
1405+
$comment_args['paged'] = 1;
1406+
} elseif ( 'newest' === $default_page ) {
1407+
$comment_args['paged'] = (int) ( new WP_Comment_Query( $comment_args ) )->max_num_pages;
1408+
}
1409+
// Set the `cpage` query var to ensure the previous and next pagination links are correct
1410+
// when inheriting the Discussion Settings.
1411+
if ( 0 === $page && isset( $comment_args['paged'] ) && $comment_args['paged'] > 0 ) {
1412+
set_query_var( 'cpage', $comment_args['paged'] );
1413+
}
14131414
}
14141415
}
14151416

0 commit comments

Comments
 (0)