Omit cpage
query var in comment link if comment pagination is disabled.
WP 4.4 changed the way comment pagination is calculated. See #8071. In the context of `get_comment_link()`, these changes introduced a regression that causes `cpage` (or its pretty-permalink correlate `comment-page-x`) to appear in comment links when comment pagination is disabled. The current changeset fixes the regression. Fixes #34946. git-svn-id: https://develop.svn.wordpress.org/trunk@35933 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
4732139799
commit
42fe7609c7
@ -736,7 +736,7 @@ function get_comment_link( $comment = null, $args = array() ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $cpage ) {
|
||||
if ( $cpage && get_option( 'page_comments' ) ) {
|
||||
if ( $wp_rewrite->using_permalinks() ) {
|
||||
if ( $cpage ) {
|
||||
$link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;
|
||||
|
@ -128,4 +128,16 @@ class Tests_Comment_GetCommentLink extends WP_UnitTestCase {
|
||||
|
||||
$this->assertContains( 'cpage=3', $found );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 34946
|
||||
*/
|
||||
public function test_should_not_contain_comment_page_1_when_pagination_is_disabled() {
|
||||
$this->set_permalink_structure( '/%postname%/' );
|
||||
update_option( 'page_comments', 0 );
|
||||
|
||||
$found = get_comment_link( self::$comments[1] );
|
||||
|
||||
$this->assertNotContains( 'comment-page-1', $found );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user