WordPress.org

Make WordPress Core

Ticket #12006: comment_ID.arugment-sans-ternary.12006.diff

File comment_ID.arugment-sans-ternary.12006.diff, 8.1 KB (added by filosofo, 6 years ago)
  • wp-includes/comment-template.php

     
    1717 * @since 1.5.0 
    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)){ 
    2627                        $user=get_userdata($comment->user_id); 
     
    3940 * 
    4041 * @since 0.71 
    4142 * @uses apply_filters() Calls 'comment_author' on comment author before displaying 
     43 *  
     44 * @param int $comment_ID The ID of the comment for which to print the author. Optional. 
    4245 */ 
    43 function comment_author() { 
    44         $author = apply_filters('comment_author', get_comment_author() ); 
     46function comment_author( $comment_ID = 0 ) { 
     47        $author = apply_filters('comment_author', get_comment_author( $comment_ID ) ); 
    4548        echo $author; 
    4649} 
    4750 
     
    5255 * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email 
    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} 
    6165 
     
    7074 * 
    7175 * @since 0.71 
    7276 * @uses apply_filters() Calls 'author_email' hook on the author email 
     77 * 
     78 * @param int $comment_ID The ID of the comment for which to print the author's email. Optional. 
    7379 */ 
    74 function comment_author_email() { 
    75         echo apply_filters('author_email', get_comment_author_email() ); 
     80function comment_author_email( $comment_ID = 0 ) { 
     81        echo apply_filters('author_email', get_comment_author_email( $comment_ID ) ); 
    7682} 
    7783 
    7884/** 
     
    135141 * @since 1.5.0 
    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 ) 
    146153                $return = $author; 
     
    154161 * 
    155162 * @since 0.71 
    156163 * @see get_comment_author_link() Echos result 
     164 * 
     165 * @param int The ID of the comment for which to print the author's link. Optional. 
    157166 */ 
    158 function comment_author_link() { 
    159         echo get_comment_author_link(); 
     167function comment_author_link( $comment_ID = 0 ) { 
     168        echo get_comment_author_link( $comment_ID ); 
    160169} 
    161170 
    162171/** 
     
    166175 * @uses $comment 
    167176 * @uses apply_filters() 
    168177 * 
    169  * @return unknown 
     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. 
    170180 */ 
    171 function get_comment_author_IP() { 
    172         global $comment; 
     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} 
    175185 
     
    178188 * 
    179189 * @since 0.71 
    180190 * @see get_comment_author_IP() Echos Result 
     191 * 
     192 * @param int $comment_ID The ID of the comment for which to print the author's IP address.  Optional. 
    181193 */ 
    182 function comment_author_IP() { 
    183         echo get_comment_author_IP(); 
     194function comment_author_IP( $comment_ID = 0 ) { 
     195        echo get_comment_author_IP( $comment_ID ); 
    184196} 
    185197 
    186198/** 
     
    189201 * @since 1.5.0 
    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') ); 
    198211        return apply_filters('get_comment_author_url', $url); 
     
    204217 * @since 0.71 
    205218 * @uses apply_filters() 
    206219 * @uses get_comment_author_url() Retrieves the comment author's URL 
     220 * 
     221 * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional. 
    207222 */ 
    208 function comment_author_url() { 
    209         echo apply_filters('comment_url', get_comment_author_url()); 
     223function comment_author_url( $comment_ID = 0 ) { 
     224        echo apply_filters('comment_url', get_comment_author_url( $comment_ID )); 
    210225} 
    211226 
    212227/** 
     
    351366 * @uses $comment 
    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); 
    360376        else 
     
    368384 * @since 0.71 
    369385 * 
    370386 * @param string $d The format of the date (defaults to user's config) 
     387 * @param int $comment_ID The ID of the comment for which to print the date.  Optional. 
    371388 */ 
    372 function comment_date( $d = '' ) { 
    373         echo get_comment_date( $d ); 
     389function comment_date( $d = '', $comment_ID = 0 ) { 
     390        echo get_comment_date( $d, $comment_ID ); 
    374391} 
    375392 
    376393/** 
     
    384401 * @uses $comment 
    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); 
    393411        if (count($blah) > 20) { 
     
    410428 * 
    411429 * @since 1.2.0 
    412430 * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt 
     431 * 
     432 * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional. 
    413433 */ 
    414 function comment_excerpt() { 
     434function comment_excerpt( $comment_ID = 0 ) { 
    415435        echo apply_filters('comment_excerpt', get_comment_excerpt() ); 
    416436} 
    417437 
     
    575595 * @since 1.5.0 
    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} 
    584605 
     
    588609 * @since 0.71 
    589610 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display 
    590611 * @uses get_comment_text() Gets the comment content 
     612 * 
     613 * @param int $comment_ID The ID of the comment for which to print the text. Optional. 
    591614 */ 
    592 function comment_text() { 
     615function comment_text( $comment_ID = 0 ) { 
    593616        echo apply_filters('comment_text', get_comment_text() ); 
    594617} 
    595618 
     
    633656 * @uses $comment 
    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'; 
    643666