From 44a0e46c8579bea1e34d364d212424228244bb69 Mon Sep 17 00:00:00 2001 From: gziolo Date: Mon, 11 Apr 2022 16:35:10 +0000 Subject: [PATCH] Editor: Update `build_comment_query_vars_from_block` from Gutenberg Follow-up for [53138]. See #55505. Built from https://develop.svn.wordpress.org/trunk@53142 git-svn-id: http://core.svn.wordpress.org/trunk@52731 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 35 ++++++++++++++++++----------------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 72f0198626..dea94f173e 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -1392,24 +1392,25 @@ function build_comment_query_vars_from_block( $block ) { $comment_args['hierarchical'] = false; } - $per_page = get_option( 'comments_per_page' ); - $default_page = get_option( 'default_comments_page' ); + if ( get_option( 'page_comments' ) === '1' || get_option( 'page_comments' ) === true ) { + $per_page = get_option( 'comments_per_page' ); + $default_page = get_option( 'default_comments_page' ); + if ( $per_page > 0 ) { + $comment_args['number'] = $per_page; - if ( $per_page > 0 ) { - $comment_args['number'] = $per_page; - - $page = (int) get_query_var( 'cpage' ); - if ( $page ) { - $comment_args['paged'] = $page; - } elseif ( 'oldest' === $default_page ) { - $comment_args['paged'] = 1; - } elseif ( 'newest' === $default_page ) { - $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'] ); + $page = (int) get_query_var( 'cpage' ); + if ( $page ) { + $comment_args['paged'] = $page; + } elseif ( 'oldest' === $default_page ) { + $comment_args['paged'] = 1; + } elseif ( 'newest' === $default_page ) { + $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'] ); + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 37e198b8e4..4017bc4a0a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53141'; +$wp_version = '6.0-alpha-53142'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.