Ticket #12006: comment_ID.argument.12006.diff
File comment_ID.argument.12006.diff, 9.6 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 function get_comment_author( $comment_ID = 0 ) { 23 24 global $comment; 24 if ( empty($comment->comment_author) ) { 25 if (!empty($comment->user_id)){ 26 $user=get_userdata($comment->user_id); 25 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 26 if ( empty($_comment->comment_author) ) { 27 if (!empty($_comment->user_id)){ 28 $user=get_userdata($_comment->user_id); 27 29 $author=$user->user_login; 28 30 } else { 29 31 $author = __('Anonymous'); 30 32 } 31 33 } else { 32 $author = $ comment->comment_author;34 $author = $_comment->comment_author; 33 35 } 34 36 return apply_filters('get_comment_author', $author); 35 37 } … … 39 41 * 40 42 * @since 0.71 41 43 * @uses apply_filters() Calls 'comment_author' on comment author before displaying 44 * 45 * @param int $comment_ID The ID of the comment for which to print the author. Optional. 42 46 */ 43 function comment_author( ) {44 $author = apply_filters('comment_author', get_comment_author( ) );47 function comment_author( $comment_ID = 0 ) { 48 $author = apply_filters('comment_author', get_comment_author( $comment_ID ) ); 45 49 echo $author; 46 50 } 47 51 … … 52 56 * @uses apply_filters() Calls the 'get_comment_author_email' hook on the comment author email 53 57 * @uses $comment 54 58 * 59 * @param int $comment_ID The ID of the comment for which to get the author's email. Optional. 55 60 * @return string The current comment author's email 56 61 */ 57 function get_comment_author_email( ) {62 function get_comment_author_email( $comment_ID = 0 ) { 58 63 global $comment; 59 return apply_filters('get_comment_author_email', $comment->comment_author_email); 64 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 65 return apply_filters('get_comment_author_email', $_comment->comment_author_email); 60 66 } 61 67 62 68 /** … … 70 76 * 71 77 * @since 0.71 72 78 * @uses apply_filters() Calls 'author_email' hook on the author email 79 * 80 * @param int $comment_ID The ID of the comment for which to print the author's email. Optional. 73 81 */ 74 function comment_author_email( ) {75 echo apply_filters('author_email', get_comment_author_email( ) );82 function comment_author_email( $comment_ID = 0 ) { 83 echo apply_filters('author_email', get_comment_author_email( $comment_ID ) ); 76 84 } 77 85 78 86 /** … … 135 143 * @since 1.5.0 136 144 * @uses apply_filters() Calls 'get_comment_author_link' hook on the complete link HTML or author 137 145 * 146 * @param int $comment_ID The ID of the comment for which to get the author's link. Optional. 138 147 * @return string Comment Author name or HTML link for author's URL 139 148 */ 140 function get_comment_author_link( ) {149 function get_comment_author_link( $comment_ID = 0 ) { 141 150 /** @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( );151 $url = get_comment_author_url( $comment_ID ); 152 $author = get_comment_author( $comment_ID ); 144 153 145 154 if ( empty( $url ) || 'http://' == $url ) 146 155 $return = $author; … … 154 163 * 155 164 * @since 0.71 156 165 * @see get_comment_author_link() Echos result 166 * 167 * @param int The ID of the comment for which to print the author's link. Optional. 157 168 */ 158 function comment_author_link( ) {159 echo get_comment_author_link( );169 function comment_author_link( $comment_ID = 0 ) { 170 echo get_comment_author_link( $comment_ID ); 160 171 } 161 172 162 173 /** … … 166 177 * @uses $comment 167 178 * @uses apply_filters() 168 179 * 169 * @return unknown 180 * @param int $comment_ID The ID of the comment for which to get the author's IP address. Optional. 181 * @return string The comment author's IP address. 170 182 */ 171 function get_comment_author_IP( ) {183 function get_comment_author_IP( $comment_ID = 0 ) { 172 184 global $comment; 173 return apply_filters('get_comment_author_IP', $comment->comment_author_IP); 185 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 186 return apply_filters('get_comment_author_IP', $_comment->comment_author_IP); 174 187 } 175 188 176 189 /** … … 178 191 * 179 192 * @since 0.71 180 193 * @see get_comment_author_IP() Echos Result 194 * 195 * @param int $comment_ID The ID of the comment for which to print the author's IP address. Optional. 181 196 */ 182 function comment_author_IP( ) {183 echo get_comment_author_IP( );197 function comment_author_IP( $comment_ID = 0 ) { 198 echo get_comment_author_IP( $comment_ID ); 184 199 } 185 200 186 201 /** … … 189 204 * @since 1.5.0 190 205 * @uses apply_filters() Calls 'get_comment_author_url' hook on the comment author's URL 191 206 * 207 * @param int $comment_ID The ID of the comment for which to get the author's URL. Optional. 192 208 * @return string 193 209 */ 194 function get_comment_author_url( ) {210 function get_comment_author_url( $comment_ID = 0 ) { 195 211 global $comment; 196 $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url; 212 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 213 $url = ('http://' == $_comment->comment_author_url) ? '' : $_comment->comment_author_url; 197 214 $url = esc_url( $url, array('http', 'https') ); 198 215 return apply_filters('get_comment_author_url', $url); 199 216 } … … 204 221 * @since 0.71 205 222 * @uses apply_filters() 206 223 * @uses get_comment_author_url() Retrieves the comment author's URL 224 * 225 * @param int $comment_ID The ID of the comment for which to print the author's URL. Optional. 207 226 */ 208 function comment_author_url( ) {209 echo apply_filters('comment_url', get_comment_author_url( ));227 function comment_author_url( $comment_ID = 0 ) { 228 echo apply_filters('comment_url', get_comment_author_url( $comment_ID )); 210 229 } 211 230 212 231 /** … … 351 370 * @uses $comment 352 371 * 353 372 * @param string $d The format of the date (defaults to user's config) 373 * @param int $comment_ID The ID of the comment for which to get the date. Optional. 354 374 * @return string The comment's date 355 375 */ 356 function get_comment_date( $d = '' ) {376 function get_comment_date( $d = '', $comment_ID = 0 ) { 357 377 global $comment; 378 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 358 379 if ( '' == $d ) 359 $date = mysql2date(get_option('date_format'), $ comment->comment_date);380 $date = mysql2date(get_option('date_format'), $_comment->comment_date); 360 381 else 361 $date = mysql2date($d, $ comment->comment_date);382 $date = mysql2date($d, $_comment->comment_date); 362 383 return apply_filters('get_comment_date', $date, $d); 363 384 } 364 385 … … 368 389 * @since 0.71 369 390 * 370 391 * @param string $d The format of the date (defaults to user's config) 392 * @param int $comment_ID The ID of the comment for which to print the date. Optional. 371 393 */ 372 function comment_date( $d = '' ) {373 echo get_comment_date( $d );394 function comment_date( $d = '', $comment_ID = 0 ) { 395 echo get_comment_date( $d, $comment_ID ); 374 396 } 375 397 376 398 /** … … 384 406 * @uses $comment 385 407 * @uses apply_filters() Calls 'get_comment_excerpt' on truncated comment 386 408 * 409 * @param int $comment_ID The ID of the comment for which to get the excerpt. Optional. 387 410 * @return string The maybe truncated comment with 20 words or less 388 411 */ 389 function get_comment_excerpt( ) {412 function get_comment_excerpt( $comment_ID = 0 ) { 390 413 global $comment; 391 $comment_text = strip_tags($comment->comment_content); 414 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 415 $comment_text = strip_tags($_comment->comment_content); 392 416 $blah = explode(' ', $comment_text); 393 417 if (count($blah) > 20) { 394 418 $k = 20; … … 410 434 * 411 435 * @since 1.2.0 412 436 * @uses apply_filters() Calls 'comment_excerpt' hook before displaying excerpt 437 * 438 * @param int $comment_ID The ID of the comment for which to print the excerpt. Optional. 413 439 */ 414 function comment_excerpt( ) {440 function comment_excerpt( $comment_ID = 0 ) { 415 441 echo apply_filters('comment_excerpt', get_comment_excerpt() ); 416 442 } 417 443 … … 575 601 * @since 1.5.0 576 602 * @uses $comment 577 603 * 604 * @param int $comment_ID The ID of the comment for which to get the text. Optional. 578 605 * @return string The comment content 579 606 */ 580 function get_comment_text( ) {607 function get_comment_text( $comment_ID = 0 ) { 581 608 global $comment; 582 return apply_filters('get_comment_text', $comment->comment_content); 609 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 610 return apply_filters('get_comment_text', $_comment->comment_content); 583 611 } 584 612 585 613 /** … … 588 616 * @since 0.71 589 617 * @uses apply_filters() Passes the comment content through the 'comment_text' hook before display 590 618 * @uses get_comment_text() Gets the comment content 619 * 620 * @param int $comment_ID The ID of the comment for which to print the text. Optional. 591 621 */ 592 function comment_text( ) {622 function comment_text( $comment_ID = 0 ) { 593 623 echo apply_filters('comment_text', get_comment_text() ); 594 624 } 595 625 … … 633 663 * @uses $comment 634 664 * @uses apply_filters() Calls the 'get_comment_type' hook on the comment type 635 665 * 666 * @param int $comment_ID The ID of the comment for which to get the type. Optional. 636 667 * @return string The comment type 637 668 */ 638 function get_comment_type( ) {669 function get_comment_type( $comment_ID = 0 ) { 639 670 global $comment; 640 671 641 if ( '' == $comment->comment_type ) 642 $comment->comment_type = 'comment'; 672 $_comment = empty( $comment_ID ) ? $comment : get_comment( $comment_ID ); 673 if ( '' == $_comment->comment_type ) 674 $_comment->comment_type = 'comment'; 643 675 644 return apply_filters('get_comment_type', $ comment->comment_type);676 return apply_filters('get_comment_type', $_comment->comment_type); 645 677 } 646 678 647 679 /**