diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 854cbe73b3..84a60dbc4a 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -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; diff --git a/tests/phpunit/tests/comment/getCommentLink.php b/tests/phpunit/tests/comment/getCommentLink.php index 32c490bdb2..fac5fa0d7f 100644 --- a/tests/phpunit/tests/comment/getCommentLink.php +++ b/tests/phpunit/tests/comment/getCommentLink.php @@ -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 ); + } }