From 11db0d3b01c032f18a6c20880481a0f46a0a4d0b Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Sat, 21 Sep 2013 18:18:09 +0000 Subject: [PATCH] Add an `$args` parameter to `comment_text` and `get_comment_text` filters. Adds filter docs. Improve docblocks for `get_comment_text()` and `comment_text()`. Props simonwheatley, ericlewis, DrewAPicture. Fixes #14856. Built from https://develop.svn.wordpress.org/trunk@25555 git-svn-id: http://core.svn.wordpress.org/trunk@25475 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/comment-template.php | 48 ++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index 8a686582e0..c2dc8fb46f 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -591,28 +591,52 @@ function comments_number( $zero = false, $one = false, $more = false, $deprecate * Retrieve the text of the current comment. * * @since 1.5.0 - * @uses $comment * - * @param int $comment_ID The ID of the comment for which to get the text. Optional. - * @return string The comment content + * @param int $comment_ID Optional. The ID of the comment for which to get the text. + * Default 0. + * @param array $args Optional. An array of arguments. @see Walker_Comment::comment() + * Default empty array. + * @return string The comment content. */ -function get_comment_text( $comment_ID = 0 ) { +function get_comment_text( $comment_ID = 0, $args = array() ) { $comment = get_comment( $comment_ID ); - return apply_filters( 'get_comment_text', $comment->comment_content, $comment ); + + /** + * Filter the text of a comment. + * + * @since 1.5.2 + * + * @param string $comment->comment_content The text of the comment. + * @param object $comment The comment object. + * @param array $args An array of arguments. @see Walker_Comment::comment() + */ + return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args ); } /** - * Displays the text of the current comment. + * Display the text of the current comment. * * @since 0.71 - * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display - * @uses get_comment_text() Gets the comment content * - * @param int $comment_ID The ID of the comment for which to print the text. Optional. + * @param int $comment_ID Optional. The ID of the comment for which to print the text. + * Default 0. + * @param array $args Optional. An array of arguments. @see Walker_Comment::comment() + * Default empty array. */ -function comment_text( $comment_ID = 0 ) { +function comment_text( $comment_ID = 0, $args = array() ) { $comment = get_comment( $comment_ID ); - echo apply_filters( 'comment_text', get_comment_text( $comment_ID ), $comment ); + + $comment_text = get_comment_text( $comment_ID , $args ); + /** + * Filter the text of a comment to be displayed. + * + * @since 1.2.1 + * + * @param string $comment_text The text of the current comment. + * @param object $comment The comment object. + * @param array $args An array of arguments. @see Walker_Comment::comment() + */ + echo apply_filters( 'comment_text', $comment_text, $comment, $args ); } /** @@ -1452,7 +1476,7 @@ class Walker_Comment extends Walker { ?> - + $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
$add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>