From 50fd820621fb7cd25d7a6e1e67e05abbcbba91a6 Mon Sep 17 00:00:00 2001 From: joedolson Date: Mon, 7 Jun 2021 21:49:59 +0000 Subject: [PATCH] Comments: Return valid comment reply link if comments are paginated. Fix the link returned by `get_comment_reply_link()` so the link points to the correct page of comments when links are paginated. While this link is normally overridden by the comment-reply script, if that script is disabled, the link would point to a location that did not exist when comments were paginated. props MrPauloEn, paaggeli, alexstine, engahmeds3ed. Fixes #51189. Built from https://develop.svn.wordpress.org/trunk@51081 git-svn-id: http://core.svn.wordpress.org/trunk@50690 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 10 ++++++++-- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 4c1b134e3a..b189970d58 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -1647,7 +1647,7 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c * * @since 2.7.0 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. - * + * * @param array $args { * Optional. Override default arguments. * @@ -1706,6 +1706,12 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null return false; } + if ( get_option( 'page_comments' ) ) { + $permalink = str_replace( '#comment-' . $comment->comment_ID, '', get_comment_link( $comment ) ); + } else { + $permalink = get_permalink( $post->ID ); + } + /** * Filters the comment reply link arguments. * @@ -1750,7 +1756,7 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null 'unapproved' => false, 'moderation-hash' => false, ), - get_permalink( $post->ID ) + $permalink ) ) . '#' . $args['respond_id'], $data_attribute_string, diff --git a/wp-includes/version.php b/wp-includes/version.php index 87ca5e8a26..5c76d4dd4e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-alpha-51080'; +$wp_version = '5.8-alpha-51081'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.