Make WordPress Core

Changeset 30092


Ignore:
Timestamp:
10/29/2014 07:07:00 PM (12 years ago)
Author:
westi
Message:

Comment Template Tags: Improve the availability of context information in comment template tag filters.

Fixes #22380 props momo360modena, tareq1988.

File:
1 edited

Legend:

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

    r30039 r30092  
    3737         * @since 1.5.0
    3838         *
    39          * @param string $author The comment author's username.
    40          */
    41         return apply_filters( 'get_comment_author', $author );
     39         * @param string $author     The comment author's username.
     40         * @param int    $comment_ID The comment ID
     41         * @param object $comment    The comment
     42         */
     43        return apply_filters( 'get_comment_author', $author, $comment_ID, $comment );
    4244}
    4345
    … …  
    5759         *
    5860         * @param string $author The comment author's username.
    59          */
    60         $author = apply_filters( 'comment_author', $author );
     61         * @param int    $comment_ID The comment ID
     62         */
     63        $author = apply_filters( 'comment_author', $author, $comment_ID );
    6164        echo $author;
    6265}
    … …  
    7881         *
    7982         * @param string $comment_author_email The comment author's email address.
    80          */
    81         return apply_filters( 'get_comment_author_email', $comment->comment_author_email );
     83         * @param int    $comment_ID           The comment ID
     84         * @param object $comment              The comment
     85         */
     86        return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment_ID, $comment );
    8287}
    8388
    … …  
    103108         *
    104109         * @param string $author_email The comment author's email address.
    105          */
    106         echo apply_filters( 'author_email', $author_email );
     110         * @param int    $comment_ID   The comment ID
     111         */
     112        echo apply_filters( 'author_email', $author_email, $comment_ID );
    107113}
    108114
    … …  
    157163         *
    158164         * @param string $comment_author_email The comment author's email address.
    159          */
    160         $email = apply_filters( 'comment_email', $comment->comment_author_email );
     165         * @param object $comment              The comment
     166         */
     167        $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
    161168        if ((!empty($email)) && ($email != '@')) {
    162169        $display = ($linktext != '') ? $linktext : $email;
    … …  
    196203         * @since 1.5.0
    197204         *
    198          * @param string $return The HTML-formatted comment author link.
    199          *                       Empty for an invalid URL.
    200          */
    201         return apply_filters( 'get_comment_author_link', $return );
     205         * @param string $return      The HTML-formatted comment author link.
     206         *                            Empty for an invalid URL.
     207         * @param int    $comment_ID  The comment ID
     208         */
     209        return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID );
    202210}
    203211
    … …  
    234242         *
    235243         * @param string $comment_author_IP The comment author's IP address.
    236          */
    237         return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP );
     244         * @param int    $comment_ID        The comment ID
     245         * @param object $comment           The comment
     246         */
     247        return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment_ID, $comment );
    238248}
    239249
    … …  
    268278         * @since 1.5.0
    269279         *
    270          * @param string $url The comment author's URL.
    271          */
    272         return apply_filters( 'get_comment_author_url', $url );
     280         * @param string $url                   The comment author's URL.
     281         * @param int    $comment_ID    The comment ID
     282         * @param object $comment               The comment
     283         */
     284        return apply_filters( 'get_comment_author_url', $url, $comment_ID, $comment );
    273285}
    274286
    … …  
    289301         *
    290302         * @param string $author_url The comment author's URL.
    291          */
    292         echo apply_filters( 'comment_url', $author_url );
     303         * @param int    $comment_ID The comment ID
     304         */
     305        echo apply_filters( 'comment_url', $author_url, $comment_ID );
    293306}
    294307
    … …  
    318331        $display = str_replace( 'http://www.', '', $display );
    319332        $display = str_replace( 'http://', '', $display );
    320         if ( '/' == substr($display, -1) )
     333
     334        if ( '/' == substr($display, -1) ) {
    321335                $display = substr($display, 0, -1);
     336        }
     337
    322338        $return = "$before<a href='$url' rel='external'>$display</a>$after";
    323339
    … …  
    446462         * @param string      $class      A comma-separated list of additional classes added to the list.
    447463         * @param int         $comment_id The comment id.
     464         * @param object          $comment    The comment
    448465         * @param int|WP_Post $post_id    The post ID or WP_Post object.
    449466         */
    450         return apply_filters( 'comment_class', $classes, $class, $comment_id, $post_id );
     467        return apply_filters( 'comment_class', $classes, $class, $comment_id, $comment, $post_id );
    451468}
    452469
    … …  
    507524        $comment_text = strip_tags($comment->comment_content);
    508525        $blah = explode(' ', $comment_text);
     526
    509527        if (count($blah) > 20) {
    510528                $k = 20;
    … …  
    514532                $use_dotdotdot = 0;
    515533        }
     534
    516535        $excerpt = '';
    517536        for ($i=0; $i<$k; $i++) {
    … …  
    525544         * @since 1.5.0
    526545         *
    527          * @param string $excerpt The comment excerpt text.
    528          */
    529         return apply_filters( 'get_comment_excerpt', $excerpt );
     546         * @param string $excerpt               The comment excerpt text.
     547         * @param int    $comment_ID    The comment ID
     548         * @param object $comment               The comment
     549         */
     550        return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment );
    530551}
    531552
    … …  
    545566         * @since 1.2.0
    546567         *
    547          * @param string $comment_excerpt The comment excerpt text.
    548          */
    549         echo apply_filters( 'comment_excerpt', $comment_excerpt );
     568         * @param string $comment_excerpt       The comment excerpt text.
     569         * @param int    $comment_ID            The comment ID
     570         */
     571        echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID );
    550572}
    551573
    … …  
    564586         * @since 1.5.0
    565587         *
    566          * @param int $comment_ID The current comment ID.
    567          */
    568         return apply_filters( 'get_comment_ID', $comment->comment_ID );
     588         * @param int           $comment_ID The current comment ID.
     589         * @param object    $comment    The comment
     590         */
     591        return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
    569592}
    570593
    … …  
    871894         * @since 1.5.0
    872895         *
    873          * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
    874          */
    875         return apply_filters( 'get_comment_type', $comment->comment_type );
     896         * @param string  $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
     897         * @param int     $comment_ID   The comment ID
     898         * @param object  $comment      The comment
     899         */
     900        return apply_filters( 'get_comment_type', $comment->comment_type, $comment_ID, $comment );
    876901}
    877902
Note: See TracChangeset for help on using the changeset viewer.