From b9e342c2f4e5c393328eafc5ae628c1747efa367 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 28 Sep 2016 04:19:46 +0000 Subject: [PATCH] Set default value of 'max_depth' in `get_comment_reply_link()`. Introduced in [8878]. Props d4z_c0nf. Fixes #38170. git-svn-id: https://develop.svn.wordpress.org/trunk@38669 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-template.php | 4 ++- .../tests/comment/getCommentReplyLink.php | 29 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/comment/getCommentReplyLink.php diff --git a/src/wp-includes/comment-template.php b/src/wp-includes/comment-template.php index 42ebd41e3c..581c7b71e5 100644 --- a/src/wp-includes/comment-template.php +++ b/src/wp-includes/comment-template.php @@ -1576,7 +1576,8 @@ function comments_popup_link( $zero = false, $one = false, $more = false, $css_c * Default 'respond'. * @type string $reply_text The text of the Reply link. Default 'Reply'. * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'. - * @type int $depth' The depth of the new comment. Must be greater than 0 and less than the value + * @type int $max_depth The max depth of the comment tree. Default 0. + * @type int $depth The depth of the new comment. Must be greater than 0 and less than the value * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0. * @type string $before The text or HTML to add before the reply link. Default empty. * @type string $after The text or HTML to add after the reply link. Default empty. @@ -1593,6 +1594,7 @@ function get_comment_reply_link( $args = array(), $comment = null, $post = null 'reply_text' => __( 'Reply' ), 'reply_to_text' => __( 'Reply to %s' ), 'login_text' => __( 'Log in to Reply' ), + 'max_depth' => 0, 'depth' => 0, 'before' => '', 'after' => '' diff --git a/tests/phpunit/tests/comment/getCommentReplyLink.php b/tests/phpunit/tests/comment/getCommentReplyLink.php new file mode 100644 index 0000000000..f0ce432076 --- /dev/null +++ b/tests/phpunit/tests/comment/getCommentReplyLink.php @@ -0,0 +1,29 @@ + 5, + 'max_depth' => 4, + ); + + $this->assertNull( get_comment_reply_link( $args ) ); + } + + /** + * @ticket 38170 + */ + public function test_should_return_null_when_default_max_depth_is_less_than_depth() { + $args = array( + 'depth' => 5, + ); + + $this->assertNull( get_comment_reply_link( $args ) ); + } +}