Comments: Pass $page as argument to comments functions
Removes query alteration from `build_comment_query_vars_from_block` by introducing a new way to pass the `$page` as argument to functions handling pagination for the comments. Props cybr, santosguillamot, bernhard-reiter, gziolo. Fixes #60806. Built from https://develop.svn.wordpress.org/trunk@59081 git-svn-id: http://core.svn.wordpress.org/trunk@58477 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
71a4092291
commit
24ca39bf89
|
@ -2567,11 +2567,6 @@ function build_comment_query_vars_from_block( $block ) {
|
|||
$comment_args['paged'] = $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'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3109,21 +3109,25 @@ function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
|
|||
* Retrieves the link to the next comments page.
|
||||
*
|
||||
* @since 2.7.1
|
||||
* @since 6.7.0 Added the `page` parameter.
|
||||
*
|
||||
* @global WP_Query $wp_query WordPress Query object.
|
||||
*
|
||||
* @param string $label Optional. Label for link text. Default empty.
|
||||
* @param int $max_page Optional. Max page. Default 0.
|
||||
* @param string $label Optional. Label for link text. Default empty.
|
||||
* @param int $max_page Optional. Max page. Default 0.
|
||||
* @param int|null $page Optional. Page number. Default null.
|
||||
* @return string|void HTML-formatted link for the next page of comments.
|
||||
*/
|
||||
function get_next_comments_link( $label = '', $max_page = 0 ) {
|
||||
function get_next_comments_link( $label = '', $max_page = 0, $page = null ) {
|
||||
global $wp_query;
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$page = get_query_var( 'cpage' );
|
||||
if ( is_null( $page ) ) {
|
||||
$page = get_query_var( 'cpage' );
|
||||
}
|
||||
|
||||
if ( ! $page ) {
|
||||
$page = 1;
|
||||
|
@ -3180,16 +3184,20 @@ function next_comments_link( $label = '', $max_page = 0 ) {
|
|||
* Retrieves the link to the previous comments page.
|
||||
*
|
||||
* @since 2.7.1
|
||||
* @since 6.7.0 Added the `page` parameter.
|
||||
*
|
||||
* @param string $label Optional. Label for comments link text. Default empty.
|
||||
* @param string $label Optional. Label for comments link text. Default empty.
|
||||
* @param int|null $page Optional. Page number. Default null.
|
||||
* @return string|void HTML-formatted link for the previous page of comments.
|
||||
*/
|
||||
function get_previous_comments_link( $label = '' ) {
|
||||
function get_previous_comments_link( $label = '', $page = null ) {
|
||||
if ( ! is_singular() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$page = get_query_var( 'cpage' );
|
||||
if ( is_null( $page ) ) {
|
||||
$page = get_query_var( 'cpage' );
|
||||
}
|
||||
|
||||
if ( (int) $page <= 1 ) {
|
||||
return;
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.7-alpha-59080';
|
||||
$wp_version = '6.7-alpha-59081';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue