Make WordPress Core

Changeset 12821


Ignore:
Timestamp:
01/25/2010 05:34:13 PM (15 years ago)
Author:
ryan
Message:

Add optional comment ID argument to comment template functions. Props filosofo. fixes #12006

File:
1 edited

Legend:

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

    r12811 r12821  
    1818 * @uses apply_filters() Calls 'get_comment_author' hook on the comment author
    1919 *
     20 * @param int $comment_ID The ID of the comment for which to retrieve the author. Optional.
    2021 * @return string The comment author
    2122 */
    22 function get_comment_author() {
    23     global $comment;
     23function get_comment_author( $comment_ID = 0 ) {
     24    $comment = get_comment( $comment_ID );
    2425    if ( empty($comment->comment_author) ) {
    2526        if (!empty($comment->user_id)){
     
    4041 * @since 0.71
    4142 * @uses apply_filters() Calls 'comment_author' on comment author before displaying
    42  */
    43 function comment_author() {
    44     $author = apply_filters('comment_author', get_comment_author() );
     43 *
     44 * @param int $comment_ID The ID of the comment for which to print the author. Optional.
     45 */
     46function comment_author( $comment_ID = 0 ) {
     47    $author = apply_filters('comment_author', get_comment_author( $comment_ID ) );
    4548    echo $author;
    4649}
     
    5356 * @uses $comment
    5457 *
     58 * @param int $comment_ID The ID of the comment for which to get the author's email.  Optional.
    5559 * @return string The current comment author's email
    5660 */
    57 function get_comment_author_email() {
    58     global $comment;
     61function get_comment_author_email( $comment_ID = 0 ) {
     62    $comment = get_comment( $comment_ID );
    5963    return apply_filters('get_comment_author_email', $comment->comment_author_email);
    6064}
     
    7175 * @since 0.71
    7276 * @uses apply_filters() Calls 'author_email' hook on the author email
    73  */
    74 function comment_author_email() {
    75     echo apply_filters('author_email', get_comment_author_email() );
     77 *
     78 * @param int $comment_ID The ID of the comment for which to print the author's email. Optional.
     79 */
     80function comment_author_email( $comment_ID = 0 ) {
     81    echo apply_filters('author_email', get_comment_author_email( $comment_ID ) );
    7682}
    7783
     
    136142 * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author
    137143 *
     144 * @param int $comment_ID The ID of the comment for which to get the author's link.  Optional.
    138145 * @return string Comment Author name or HTML link for author's URL
    139146 */
    140 function get_comment_author_link() {
     147function get_comment_author_link( $comment_ID = 0 ) {
    141148    /** @todo Only call these functions when they are needed. Include in if... else blocks */
    142     $url    = get_comment_author_url();
    143     $author = get_comment_author();
     149    $url    = get_comment_author_url( $comment_ID );
     150    $author = get_comment_author( $comment_ID );
    144151
    145152    if ( empty( $url ) || 'http://' == $url )
     
    155162 * @since 0.71
    156163 * @see get_comment_author_link() Echos result
    157  */
    158 function comment_author_link() {
    159     echo get_comment_author_link();
     164 *
     165 * @param int The ID of the comment for which to print the author's link. Optional.
     166 */
     167function comment_author_link( $comment_ID = 0 ) {
     168    echo get_comment_author_link( $comment_ID );
    160169}
    161170
     
    167176 * @uses apply_filters()
    168177 *
    169  * @return unknown
    170  */
    171 function get_comment_author_IP() {
    172     global $comment;
     178 * @param int $comment_ID The ID of the comment for which to get the author's IP address. Optional.
     179 * @return string The comment author's IP address.
     180 */
     181function get_comment_author_IP( $comment_ID = 0 ) {
     182    $comment = get_comment( $comment_ID );
    173183    return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
    174184}
     
    179189 * @since 0.71
    180190 * @see get_comment_author_IP() Echos Result
    181  */
    182 function comment_author_IP() {
    183     echo get_comment_author_IP();
     191 *
     192 * @param int $comment_ID The ID of the comment for which to print the author's IP address.  Optional.
     193 */
     194function comment_author_IP( $comment_ID = 0 ) {
     195    echo get_comment_author_IP( $comment_ID );
    184196}
    185197
     
    190202 * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL
    191203 *
     204 * @param int $comment_ID The ID of the comment for which to get the author's URL.  Optional.
    192205 * @return string
    193206 */
    194 function get_comment_author_url() {
    195     global $comment;
     207function get_comment_author_url( $comment_ID = 0 ) {
     208    $comment = get_comment( $comment_ID );
    196209    $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
    197210    $url = esc_url( $url, array('http', 'https') );
     
    205218 * @uses apply_filters()
    206219 * @uses get_comment_author_url() Retrieves the comment author's URL
    207  */
    208 function comment_author_url() {
    209     echo apply_filters('comment_url', get_comment_author_url());
     220 *
     221 * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional.
     222 */
     223function comment_author_url( $comment_ID = 0 ) {
     224    echo apply_filters('comment_url', get_comment_author_url( $comment_ID ));
    210225}
    211226
     
    352367 *
    353368 * @param string $d The format of the date (defaults to user's config)
     369 * @param int $comment_ID The ID of the comment for which to get the date. Optional.
    354370 * @return string The comment's date
    355371 */
    356 function get_comment_date( $d = '' ) {
    357     global $comment;
     372function get_comment_date( $d = '', $comment_ID = 0 ) {
     373    $comment = get_comment( $comment_ID );
    358374    if ( '' == $d )
    359375        $date = mysql2date(get_option('date_format'), $comment->comment_date);
     
    369385 *
    370386 * @param string $d The format of the date (defaults to user's config)
    371  */
    372 function comment_date( $d = '' ) {
    373     echo get_comment_date( $d );
     387 * @param int $comment_ID The ID of the comment for which to print the date.  Optional.
     388 */
     389function comment_date( $d = '', $comment_ID = 0 ) {
     390    echo get_comment_date( $d, $comment_ID );
    374391}
    375392
     
    385402 * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment
    386403 *
     404 * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional.
    387405 * @return string The maybe truncated comment with 20 words or less
    388406 */
    389 function get_comment_excerpt() {
    390     global $comment;
     407function get_comment_excerpt( $comment_ID = 0 ) {
     408    $comment = get_comment( $comment_ID );
    391409    $comment_text = strip_tags($comment->comment_content);
    392410    $blah = explode(' ', $comment_text);
     
    411429 * @since 1.2.0
    412430 * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt
    413  */
    414 function comment_excerpt() {
     431 *
     432 * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional.
     433 */
     434function comment_excerpt( $comment_ID = 0 ) {
    415435    echo apply_filters('comment_excerpt', get_comment_excerpt() );
    416436}
     
    576596 * @uses $comment
    577597 *
     598 * @param int $comment_ID The ID of the comment for which to get the text. Optional.
    578599 * @return string The comment content
    579600 */
    580 function get_comment_text() {
    581     global $comment;
     601function get_comment_text( $comment_ID = 0 ) {
     602    $comment = get_comment( $comment_ID );
    582603    return apply_filters('get_comment_text', $comment->comment_content);
    583604}
     
    589610 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display
    590611 * @uses get_comment_text() Gets the comment content
    591  */
    592 function comment_text() {
     612 *
     613 * @param int $comment_ID The ID of the comment for which to print the text. Optional.
     614 */
     615function comment_text( $comment_ID = 0 ) {
    593616    echo apply_filters('comment_text', get_comment_text() );
    594617}
     
    634657 * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type
    635658 *
     659 * @param int $comment_ID The ID of the comment for which to get the type. Optional.
    636660 * @return string The comment type
    637661 */
    638 function get_comment_type() {
    639     global $comment;
    640 
     662function get_comment_type( $comment_ID = 0 ) {
     663    $comment = get_comment( $comment_ID );
    641664    if ( '' == $comment->comment_type )
    642665        $comment->comment_type = 'comment';
Note: See TracChangeset for help on using the changeset viewer.