Make WordPress Core

Changeset 25555


Ignore:
Timestamp:
09/21/2013 06:17:22 PM (8 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment-template.php

    r25494 r25555  
    592592 *
    593593 * @since 1.5.0
    594  * @uses $comment
    595  *
    596  * @param int $comment_ID The ID of the comment for which to get the text. Optional.
    597  * @return string The comment content
    598  */
    599 function get_comment_text( $comment_ID = 0 ) {
     594 *
     595 * @param int   $comment_ID Optional. The ID of the comment for which to get the text.
     596 *                          Default 0.
     597 * @param array $args       Optional. An array of arguments. @see Walker_Comment::comment()
     598 *                          Default empty array.
     599 * @return string The comment content.
     600 */
     601function get_comment_text( $comment_ID = 0, $args = array() ) {
    600602    $comment = get_comment( $comment_ID );
    601     return apply_filters( 'get_comment_text', $comment->comment_content, $comment );
    602 }
    603 
    604 /**
    605  * Displays the text of the current comment.
     603
     604    /**
     605     * Filter the text of a comment.
     606     *
     607     * @since 1.5.2
     608     *
     609     * @param string $comment->comment_content The text of the comment.
     610     * @param object $comment                  The comment object.
     611     * @param array  $args                     An array of arguments. @see Walker_Comment::comment()
     612     */
     613    return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
     614}
     615
     616/**
     617 * Display the text of the current comment.
    606618 *
    607619 * @since 0.71
    608  * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
    609  * @uses get_comment_text() Gets the comment content
    610  *
    611  * @param int $comment_ID The ID of the comment for which to print the text. Optional.
    612  */
    613 function comment_text( $comment_ID = 0 ) {
     620 *
     621 * @param int   $comment_ID Optional. The ID of the comment for which to print the text.
     622 *                          Default 0.
     623 * @param array $args       Optional. An array of arguments. @see Walker_Comment::comment()
     624 *                          Default empty array.
     625 */
     626function comment_text( $comment_ID = 0, $args = array() ) {
    614627    $comment = get_comment( $comment_ID );
    615     echo apply_filters( 'comment_text', get_comment_text( $comment_ID ), $comment );
     628
     629    $comment_text = get_comment_text( $comment_ID , $args );
     630    /**
     631     * Filter the text of a comment to be displayed.
     632     *
     633     * @since 1.2.1
     634     *
     635     * @param string $comment_text The text of the current comment.
     636     * @param object $comment      The comment object.
     637     * @param array  $args         An array of arguments. @see Walker_Comment::comment()
     638     */
     639    echo apply_filters( 'comment_text', $comment_text, $comment, $args );
    616640}
    617641
     
    14531477        </div>
    14541478
    1455         <?php comment_text() ?>
     1479        <?php comment_text( get_comment_id(), array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    14561480
    14571481        <div class="reply">
Note: See TracChangeset for help on using the changeset viewer.