Ticket #12006: comment_ID.arugment-sans-ternary.12006.diff
File comment_ID.arugment-sans-ternary.12006.diff, 8.1 KB (added by , 14 years ago) |
---|
-
wp-includes/comment-template.php
17 17 * @since 1.5.0 18 18 * @uses apply_filters() Calls 'get_comment_author' hook on the comment author 19 19 * 20 * @param int $comment_ID The ID of the comment for which to retrieve the author. Optional. 20 21 * @return string The comment author 21 22 */ 22 function get_comment_author( ) {23 global $comment;23 function get_comment_author( $comment_ID = 0 ) { 24 $comment = get_comment( $comment_ID ); 24 25 if ( empty($comment->comment_author) ) { 25 26 if (!empty($comment->user_id)){ 26 27 $user=get_userdata($comment->user_id); … … 39 40 * 40 41 * @since 0.71 41 42 * @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. 42 45 */ 43 function comment_author( ) {44 $author = apply_filters('comment_author', get_comment_author( ) );46 function comment_author( $comment_ID = 0 ) { 47 $author = apply_filters('comment_author', get_comment_author( $comment_ID ) ); 45 48 echo $author; 46 49 } 47 50 … … 52 55 * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email 53 56 * @uses $comment 54 57 * 58 * @param int $comment_ID The ID of the comment for which to get the author's email. Optional. 55 59 * @return string The current comment author's email 56 60 */ 57 function get_comment_author_email( ) {58 global $comment;61 function get_comment_author_email( $comment_ID = 0 ) { 62 $comment = get_comment( $comment_ID ); 59 63 return apply_filters('get_comment_author_email', $comment->comment_author_email); 60 64 } 61 65 … … 70 74 * 71 75 * @since 0.71 72 76 * @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. 73 79 */ 74 function comment_author_email( ) {75 echo apply_filters('author_email', get_comment_author_email( ) );80 function comment_author_email( $comment_ID = 0 ) { 81 echo apply_filters('author_email', get_comment_author_email( $comment_ID ) ); 76 82 } 77 83 78 84 /** … … 135 141 * @since 1.5.0 136 142 * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author 137 143 * 144 * @param int $comment_ID The ID of the comment for which to get the author's link. Optional. 138 145 * @return string Comment Author name or HTML link for author's URL 139 146 */ 140 function get_comment_author_link( ) {147 function get_comment_author_link( $comment_ID = 0 ) { 141 148 /** @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 ); 144 151 145 152 if ( empty( $url ) || 'http://' == $url ) 146 153 $return = $author; … … 154 161 * 155 162 * @since 0.71 156 163 * @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. 157 166 */ 158 function comment_author_link( ) {159 echo get_comment_author_link( );167 function comment_author_link( $comment_ID = 0 ) { 168 echo get_comment_author_link( $comment_ID ); 160 169 } 161 170 162 171 /** … … 166 175 * @uses $comment 167 176 * @uses apply_filters() 168 177 * 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. 170 180 */ 171 function get_comment_author_IP( ) {172 global $comment;181 function get_comment_author_IP( $comment_ID = 0 ) { 182 $comment = get_comment( $comment_ID ); 173 183 return apply_filters('get_comment_author_IP', $comment->comment_author_IP); 174 184 } 175 185 … … 178 188 * 179 189 * @since 0.71 180 190 * @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. 181 193 */ 182 function comment_author_IP( ) {183 echo get_comment_author_IP( );194 function comment_author_IP( $comment_ID = 0 ) { 195 echo get_comment_author_IP( $comment_ID ); 184 196 } 185 197 186 198 /** … … 189 201 * @since 1.5.0 190 202 * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL 191 203 * 204 * @param int $comment_ID The ID of the comment for which to get the author's URL. Optional. 192 205 * @return string 193 206 */ 194 function get_comment_author_url( ) {195 global $comment;207 function get_comment_author_url( $comment_ID = 0 ) { 208 $comment = get_comment( $comment_ID ); 196 209 $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; 197 210 $url = esc_url( $url, array('http', 'https') ); 198 211 return apply_filters('get_comment_author_url', $url); … … 204 217 * @since 0.71 205 218 * @uses apply_filters() 206 219 * @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. 207 222 */ 208 function comment_author_url( ) {209 echo apply_filters('comment_url', get_comment_author_url( ));223 function comment_author_url( $comment_ID = 0 ) { 224 echo apply_filters('comment_url', get_comment_author_url( $comment_ID )); 210 225 } 211 226 212 227 /** … … 351 366 * @uses $comment 352 367 * 353 368 * @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. 354 370 * @return string The comment's date 355 371 */ 356 function get_comment_date( $d = '' ) {357 global $comment;372 function get_comment_date( $d = '', $comment_ID = 0 ) { 373 $comment = get_comment( $comment_ID ); 358 374 if ( '' == $d ) 359 375 $date = mysql2date(get_option('date_format'), $comment->comment_date); 360 376 else … … 368 384 * @since 0.71 369 385 * 370 386 * @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. 371 388 */ 372 function comment_date( $d = '' ) {373 echo get_comment_date( $d );389 function comment_date( $d = '', $comment_ID = 0 ) { 390 echo get_comment_date( $d, $comment_ID ); 374 391 } 375 392 376 393 /** … … 384 401 * @uses $comment 385 402 * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment 386 403 * 404 * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional. 387 405 * @return string The maybe truncated comment with 20 words or less 388 406 */ 389 function get_comment_excerpt( ) {390 global $comment;407 function get_comment_excerpt( $comment_ID = 0 ) { 408 $comment = get_comment( $comment_ID ); 391 409 $comment_text = strip_tags($comment->comment_content); 392 410 $blah = explode(' ', $comment_text); 393 411 if (count($blah) > 20) { … … 410 428 * 411 429 * @since 1.2.0 412 430 * @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. 413 433 */ 414 function comment_excerpt( ) {434 function comment_excerpt( $comment_ID = 0 ) { 415 435 echo apply_filters('comment_excerpt', get_comment_excerpt() ); 416 436 } 417 437 … … 575 595 * @since 1.5.0 576 596 * @uses $comment 577 597 * 598 * @param int $comment_ID The ID of the comment for which to get the text. Optional. 578 599 * @return string The comment content 579 600 */ 580 function get_comment_text( ) {581 global $comment;601 function get_comment_text( $comment_ID = 0 ) { 602 $comment = get_comment( $comment_ID ); 582 603 return apply_filters('get_comment_text', $comment->comment_content); 583 604 } 584 605 … … 588 609 * @since 0.71 589 610 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display 590 611 * @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. 591 614 */ 592 function comment_text( ) {615 function comment_text( $comment_ID = 0 ) { 593 616 echo apply_filters('comment_text', get_comment_text() ); 594 617 } 595 618 … … 633 656 * @uses $comment 634 657 * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type 635 658 * 659 * @param int $comment_ID The ID of the comment for which to get the type. Optional. 636 660 * @return string The comment type 637 661 */ 638 function get_comment_type() { 639 global $comment; 640 662 function get_comment_type( $comment_ID = 0 ) { 663 $comment = get_comment( $comment_ID ); 641 664 if ( '' == $comment->comment_type ) 642 665 $comment->comment_type = 'comment'; 643 666