Ticket #40143: 40143.patch
File 40143.patch, 30.2 KB (added by , 8 years ago) |
---|
-
src/wp-includes/comment-template.php
19 19 * 20 20 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. 21 21 * Default current comment. 22 * @return string The comment author 22 * @return string The comment author. 23 23 */ 24 24 function get_comment_author( $comment_ID = 0 ) { 25 25 $comment = get_comment( $comment_ID ); 26 26 27 if ( empty( $comment->comment_author ) ) { 28 if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) 27 if ( $comment ) { 28 if ( $comment->comment_author ) { 29 $author = $comment->comment_author; 30 } elseif ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { 29 31 $author = $user->display_name; 30 else 31 $author = __('Anonymous'); 32 } else { 33 $author = __( 'Anonymous' ); 34 } 32 35 } else { 33 $author = $comment->comment_author;36 $author = ''; 34 37 } 35 38 39 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 40 36 41 /** 37 42 * Filters the returned comment author name. 38 43 * … … 39 44 * @since 1.5.0 40 45 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 41 46 * 42 * @param string $author The comment author's username.43 * @param int $comment_ID The comment ID.44 * @param WP_Comment $comment The comment object.47 * @param string $author The comment author's username. 48 * @param int $comment_ID The comment ID. 49 * @param WP_Comment|null $comment The comment object. 45 50 */ 46 return apply_filters( 'get_comment_author', $author, $comment ->comment_ID, $comment );51 return apply_filters( 'get_comment_author', $author, $comment_ID, $comment ); 47 52 } 48 53 49 54 /** … … 56 61 * Default current comment. 57 62 */ 58 63 function comment_author( $comment_ID = 0 ) { 59 $comment = get_comment( $comment_ID ); 60 $author = get_comment_author( $comment ); 64 $comment = get_comment( $comment_ID ); 65 $author = ( $comment ) ? get_comment_author( $comment ) : ''; 66 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 61 67 62 68 /** 63 69 * Filters the comment author's name for display. … … 68 74 * @param string $author The comment author's username. 69 75 * @param int $comment_ID The comment ID. 70 76 */ 71 echo apply_filters( 'comment_author', $author, $comment ->comment_ID );77 echo apply_filters( 'comment_author', $author, $comment_ID ); 72 78 } 73 79 74 80 /** … … 79 85 * 80 86 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email. 81 87 * Default current comment. 82 * @return string The current comment author's email 88 * @return string The current comment author's email. 83 89 */ 84 90 function get_comment_author_email( $comment_ID = 0 ) { 85 $comment = get_comment( $comment_ID ); 91 $comment = get_comment( $comment_ID ); 92 $author_email = ( $comment ) ? $comment->comment_author_email : ''; 93 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 86 94 87 95 /** 88 96 * Filters the comment author's returned email address. … … 90 98 * @since 1.5.0 91 99 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 92 100 * 93 * @param string $comment_author_email The comment author's email address.94 * @param int $comment_IDThe comment ID.95 * @param WP_Comment $commentThe comment object.101 * @param string $author_email The comment author's email address. 102 * @param int $comment_ID The comment ID. 103 * @param WP_Comment|null $comment The comment object. 96 104 */ 97 return apply_filters( 'get_comment_author_email', $ comment->comment_author_email, $comment->comment_ID, $comment );105 return apply_filters( 'get_comment_author_email', $author_email, $comment_ID, $comment ); 98 106 } 99 107 100 108 /** … … 114 122 */ 115 123 function comment_author_email( $comment_ID = 0 ) { 116 124 $comment = get_comment( $comment_ID ); 117 $author_email = get_comment_author_email( $comment ); 125 $author_email = ( $comment ) ? get_comment_author_email( $comment ) : ''; 126 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 118 127 119 128 /** 120 129 * Filters the comment author's email for display. … … 125 134 * @param string $author_email The comment author's email address. 126 135 * @param int $comment_ID The comment ID. 127 136 */ 128 echo apply_filters( 'author_email', $author_email, $comment ->comment_ID );137 echo apply_filters( 'author_email', $author_email, $comment_ID ); 129 138 } 130 139 131 140 /** … … 173 182 * via the {@see 'comment_email'} filter with antispambot(). 174 183 */ 175 184 function get_comment_author_email_link( $linktext = '', $before = '', $after = '', $comment = null ) { 176 $comment = get_comment( $comment ); 185 $comment = get_comment( $comment ); 186 $author_email = ( $comment ) ? $comment->comment_author_email : ''; 177 187 178 188 /** 179 189 * Filters the comment author's email for display. … … 184 194 * @since 1.2.0 185 195 * @since 4.1.0 The `$comment` parameter was added. 186 196 * 187 * @param string $comment_author_email The comment author's email address.188 * @param WP_Comment $commentThe comment object.197 * @param string $author_email The comment author's email address. 198 * @param WP_Comment|null $comment The comment object. 189 199 */ 190 $email = apply_filters( 'comment_email', $ comment->comment_author_email, $comment );200 $email = apply_filters( 'comment_email', $author_email, $comment ); 191 201 192 if ( (!empty($email)) && ($email != '@')) {193 $display = ($linktext != '') ? $linktext : $email;202 if ( $email && '@' !== $email ) { 203 $display = ( $linktext ) ? $linktext : $email; 194 204 $return = $before; 195 205 $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); 196 206 $return .= $after; … … 214 224 * @return string The comment author name or HTML link for author's URL. 215 225 */ 216 226 function get_comment_author_link( $comment_ID = 0 ) { 217 $comment = get_comment( $comment_ID ); 218 $url = get_comment_author_url( $comment ); 219 $author = get_comment_author( $comment ); 227 $comment = get_comment( $comment_ID ); 228 $url = ( $comment ) ? get_comment_author_url( $comment ) : ''; 229 $author = ( $comment ) ? get_comment_author( $comment ) : ''; 230 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 220 231 221 232 if ( empty( $url ) || 'http://' == $url ) 222 233 $return = $author; … … 234 245 * @param string $author The comment author's username. 235 246 * @param int $comment_ID The comment ID. 236 247 */ 237 return apply_filters( 'get_comment_author_link', $return, $author, $comment ->comment_ID );248 return apply_filters( 'get_comment_author_link', $return, $author, $comment_ID ); 238 249 } 239 250 240 251 /** … … 261 272 * @return string Comment author's IP address. 262 273 */ 263 274 function get_comment_author_IP( $comment_ID = 0 ) { 264 $comment = get_comment( $comment_ID ); 275 $comment = get_comment( $comment_ID ); 276 $author_IP = ( $comment ) ? $comment->comment_author_IP : ''; 277 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 265 278 266 279 /** 267 280 * Filters the comment author's returned IP address. … … 269 282 * @since 1.5.0 270 283 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 271 284 * 272 * @param string $comment_author_IPThe comment author's IP address.273 * @param int $comment_IDThe comment ID.274 * @param WP_Comment $commentThe comment object.285 * @param string $author_IP The comment author's IP address. 286 * @param int $comment_ID The comment ID. 287 * @param WP_Comment|null $comment The comment object. 275 288 */ 276 return apply_filters( 'get_comment_author_IP', $ comment->comment_author_IP, $comment->comment_ID, $comment );289 return apply_filters( 'get_comment_author_IP', $author_IP, $comment_ID, $comment ); 277 290 } 278 291 279 292 /** … … 301 314 */ 302 315 function get_comment_author_url( $comment_ID = 0 ) { 303 316 $comment = get_comment( $comment_ID ); 304 $url = ''; 305 $id = 0; 306 if ( ! empty( $comment ) ) { 307 $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; 308 $url = esc_url( $author_url, array( 'http', 'https' ) ); 309 $id = $comment->ID; 317 318 if ( $comment && 'http://' !== $comment->comment_author_url ) { 319 $author_url = esc_url( $comment->comment_author_url, array( 'http', 'https' ) ); 320 } else { 321 $author_url = ''; 310 322 } 311 323 324 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 325 312 326 /** 313 327 * Filters the comment author's URL. 314 328 * … … 315 329 * @since 1.5.0 316 330 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 317 331 * 318 * @param string $urlThe comment author's URL.319 * @param int $comment_ID The comment ID.320 * @param WP_Comment $comment The comment object.332 * @param string $author_url The comment author's URL. 333 * @param int $comment_ID The comment ID. 334 * @param WP_Comment|null $comment The comment object. 321 335 */ 322 return apply_filters( 'get_comment_author_url', $ url, $id, $comment );336 return apply_filters( 'get_comment_author_url', $author_url, $comment_ID, $comment ); 323 337 } 324 338 325 339 /** … … 333 347 */ 334 348 function comment_author_url( $comment_ID = 0 ) { 335 349 $comment = get_comment( $comment_ID ); 336 $author_url = get_comment_author_url( $comment ); 350 $author_url = ( $comment ) ? get_comment_author_url( $comment ) : ''; 351 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 337 352 338 353 /** 339 354 * Filters the comment author's URL for display. … … 344 359 * @param string $author_url The comment author's URL. 345 360 * @param int $comment_ID The comment ID. 346 361 */ 347 echo apply_filters( 'comment_url', $author_url, $comment ->comment_ID );362 echo apply_filters( 'comment_url', $author_url, $comment_ID ); 348 363 } 349 364 350 365 /** … … 372 387 */ 373 388 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { 374 389 $url = get_comment_author_url( $comment ); 375 $display = ($linktext != '') ? $linktext : $url; 390 391 $display = ( $linktext ) ? $linktext : $url; 376 392 $display = str_replace( 'http://www.', '', $display ); 377 393 $display = str_replace( 'http://', '', $display ); 378 394 379 if ( '/' == substr( $display, -1) ) {380 $display = substr( $display, 0, -1);395 if ( '/' == substr( $display, -1 ) ) { 396 $display = substr( $display, 0, -1 ); 381 397 } 382 398 383 399 $return = "$before<a href='$url' rel='external'>$display</a>$after"; … … 531 547 * @since 1.5.0 532 548 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. 533 549 * 534 * @param string $d 535 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date.536 * Default current comment.550 * @param string $date_format Optional. The format of the date. Default user's setting. 551 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date. 552 * Default current comment. 537 553 * @return string The comment's date. 538 554 */ 539 function get_comment_date( $d = '', $comment_ID = 0 ) {555 function get_comment_date( $date_format = '', $comment_ID = 0 ) { 540 556 $comment = get_comment( $comment_ID ); 541 if ( '' == $d ) 542 $date = mysql2date(get_option('date_format'), $comment->comment_date); 543 else 544 $date = mysql2date($d, $comment->comment_date); 557 558 if ( $comment ) { 559 if ( ! $date_format ) { 560 $date = mysql2date( get_option( 'date_format' ), $comment->comment_date ); 561 } else { 562 $date = mysql2date( $date_format, $comment->comment_date ); 563 } 564 } else { 565 $date = ''; 566 } 567 545 568 /** 546 569 * Filters the returned comment date. 547 570 * 548 571 * @since 1.5.0 549 572 * 550 * @param string|int $dateFormatted date string or Unix timestamp.551 * @param string $dThe format of the date.552 * @param WP_Comment $commentThe comment object.573 * @param string|int $date Formatted date string or Unix timestamp. 574 * @param string $date_format The format of the date. 575 * @param WP_Comment|null $comment The comment object. 553 576 */ 554 return apply_filters( 'get_comment_date', $date, $d , $comment );577 return apply_filters( 'get_comment_date', $date, $date_format, $comment ); 555 578 } 556 579 557 580 /** … … 560 583 * @since 0.71 561 584 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. 562 585 * 563 * @param string $d 564 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date.565 * Default current comment.586 * @param string $date_format Optional. The format of the date. Default user's settings. 587 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date. 588 * Default current comment. 566 589 */ 567 function comment_date( $d = '', $comment_ID = 0 ) {568 echo get_comment_date( $d , $comment_ID );590 function comment_date( $date_format = '', $comment_ID = 0 ) { 591 echo get_comment_date( $date_format, $comment_ID ); 569 592 } 570 593 571 594 /** … … 583 606 * @return string The maybe truncated comment with 20 words or less. 584 607 */ 585 608 function get_comment_excerpt( $comment_ID = 0 ) { 586 $comment = get_comment( $comment_ID ); 587 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); 609 $comment = get_comment( $comment_ID ); 610 $comment_text = ( $comment ) ? $comment->comment_content : ''; 611 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 612 613 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment_text ) ); 614 588 615 $words = explode( ' ', $comment_text ); 589 616 590 617 /** … … 611 638 * @since 1.5.0 612 639 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 613 640 * 614 * @param string $excerpt The comment excerpt text.615 * @param int $comment_ID The comment ID.616 * @param WP_Comment $comment The comment object.641 * @param string $excerpt The comment excerpt text. 642 * @param int $comment_ID The comment ID. 643 * @param WP_Comment|null $comment The comment object. 617 644 */ 618 return apply_filters( 'get_comment_excerpt', $excerpt, $comment ->comment_ID, $comment );645 return apply_filters( 'get_comment_excerpt', $excerpt, $comment_ID, $comment ); 619 646 } 620 647 621 648 /** … … 629 656 */ 630 657 function comment_excerpt( $comment_ID = 0 ) { 631 658 $comment = get_comment( $comment_ID ); 632 $comment_excerpt = get_comment_excerpt( $comment ); 659 $comment_excerpt = ( $comment ) ? get_comment_excerpt( $comment ) : ''; 660 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 633 661 634 662 /** 635 663 * Filters the comment excerpt for display. … … 640 668 * @param string $comment_excerpt The comment excerpt text. 641 669 * @param int $comment_ID The comment ID. 642 670 */ 643 echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment ->comment_ID );671 echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment_ID ); 644 672 } 645 673 646 674 /** … … 651 679 * @return int The comment ID. 652 680 */ 653 681 function get_comment_ID() { 654 $comment = get_comment(); 682 $comment = get_comment(); 683 $comment_ID = ( $comment ) ? $comment->comment_ID : 0; 655 684 656 685 /** 657 686 * Filters the returned comment ID. … … 659 688 * @since 1.5.0 660 689 * @since 4.1.0 The `$comment_ID` parameter was added. 661 690 * 662 * @param int $comment_ID The current comment ID.663 * @param WP_Comment $comment The comment object.691 * @param int $comment_ID The current comment ID. 692 * @param WP_Comment|null $comment The comment object. 664 693 */ 665 return apply_filters( 'get_comment_ID', $comment ->comment_ID, $comment );694 return apply_filters( 'get_comment_ID', $comment_ID, $comment ); 666 695 } 667 696 668 697 /** … … 702 731 function get_comment_link( $comment = null, $args = array() ) { 703 732 global $wp_rewrite, $in_comment_loop; 704 733 705 $comment = get_comment( $comment);734 $comment = get_comment( $comment ); 706 735 707 736 // Back-compat. 708 737 if ( ! is_array( $args ) ) { … … 718 747 ); 719 748 $args = wp_parse_args( $args, $defaults ); 720 749 721 $link = get_permalink( $comment->comment_post_ID );750 $link = ( $comment ) ? get_permalink( $comment->comment_post_ID ) : ''; 722 751 723 752 // The 'cpage' param takes precedence. 724 753 if ( ! is_null( $args['cpage'] ) ) { … … 742 771 $cpage = get_query_var( 'cpage' ); 743 772 } else { 744 773 // Requires a database hit, so we only do it when we can't figure out from context. 745 $cpage = get_page_of_comment( $comment->comment_ID, $args );774 $cpage = ( $comment ) ? get_page_of_comment( $comment->comment_ID, $args ) : 0; 746 775 } 747 776 } 748 777 … … 768 797 769 798 } 770 799 771 if ( $ wp_rewrite->using_permalinks() ) {800 if ( $link && $wp_rewrite->using_permalinks() ) { 772 801 $link = user_trailingslashit( $link, 'comment' ); 773 802 } 774 803 775 $link = $link . '#comment-' . $comment->comment_ID;804 $link = ( $link ) ? $link . '#comment-' . $comment->comment_ID : ''; 776 805 777 806 /** 778 807 * Filters the returned single comment permalink. … … 782 811 * 783 812 * @see get_page_of_comment() 784 813 * 785 * @param string $link The comment permalink with '#comment-$id' appended.786 * @param WP_Comment $comment The current comment object.787 * @param array $args An array of arguments to override the defaults.788 * @param int $cpage The calculated 'cpage' value.814 * @param string $link The comment permalink with '#comment-$id' appended. 815 * @param WP_Comment|null $comment The current comment object. 816 * @param array $args An array of arguments to override the defaults. 817 * @param int $cpage The calculated 'cpage' value. 789 818 */ 790 819 return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage ); 791 820 } … … 949 978 * @return string The comment content. 950 979 */ 951 980 function get_comment_text( $comment_ID = 0, $args = array() ) { 952 $comment = get_comment( $comment_ID ); 981 $comment = get_comment( $comment_ID ); 982 $comment_text = ( $comment ) ? $comment->comment_content : ''; 953 983 954 984 /** 955 985 * Filters the text of a comment. … … 958 988 * 959 989 * @see Walker_Comment::comment() 960 990 * 961 * @param string $comment_content Text of the comment.962 * @param WP_Comment $comment The comment object.963 * @param array $args An array of arguments.991 * @param string $comment_content Text of the comment. 992 * @param WP_Comment|null $comment The comment object. 993 * @param array $args An array of arguments. 964 994 */ 965 return apply_filters( 'get_comment_text', $comment ->comment_content, $comment, $args );995 return apply_filters( 'get_comment_text', $comment_text, $comment, $args ); 966 996 } 967 997 968 998 /** … … 978 1008 * @param array $args Optional. An array of arguments. Default empty array. Default empty. 979 1009 */ 980 1010 function comment_text( $comment_ID = 0, $args = array() ) { 981 $comment = get_comment( $comment_ID ); 1011 $comment = get_comment( $comment_ID ); 1012 $comment_text = ( $comment ) ? get_comment_text( $comment, $args ) : ''; 982 1013 983 $comment_text = get_comment_text( $comment, $args );984 1014 /** 985 1015 * Filters the text of a comment to be displayed. 986 1016 * … … 988 1018 * 989 1019 * @see Walker_Comment::comment() 990 1020 * 991 * @param string $comment_text Text of the current comment.992 * @param WP_Comment $comment The comment object.993 * @param array $args An array of arguments.1021 * @param string $comment_text Text of the current comment. 1022 * @param WP_Comment|null $comment The comment object. 1023 * @param array $args An array of arguments. 994 1024 */ 995 1025 echo apply_filters( 'comment_text', $comment_text, $comment, $args ); 996 1026 } … … 1000 1030 * 1001 1031 * @since 1.5.0 1002 1032 * 1003 * @param string $ dOptional. The format of the time. Default user's settings.1004 * @param bool $gmt Optional. Whether to use the GMT date. Default false.1005 * @param bool $translate Optional. Whether to translate the time (for use in feeds).1006 * Default true.1033 * @param string $time_format Optional. The format of the time. Default user's settings. 1034 * @param bool $gmt Optional. Whether to use the GMT date. Default false. 1035 * @param bool $translate Optional. Whether to translate the time (for use in feeds). 1036 * Default true. 1007 1037 * @return string The formatted time. 1008 1038 */ 1009 function get_comment_time( $ d= '', $gmt = false, $translate = true ) {1039 function get_comment_time( $time_format = '', $gmt = false, $translate = true ) { 1010 1040 $comment = get_comment(); 1011 1041 1012 $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date; 1013 if ( '' == $d ) 1014 $date = mysql2date(get_option('time_format'), $comment_date, $translate); 1015 else 1016 $date = mysql2date($d, $comment_date, $translate); 1042 if ( $comment ) { 1043 $comment_time = ( $gmt ) ? $comment->comment_date_gmt : $comment->comment_date; 1044 if ( ! $time_format ) { 1045 $time = mysql2date( get_option( 'time_format' ), $comment_time, $translate ); 1046 } else { 1047 $time = mysql2date( $time_format, $comment_time, $translate ); 1048 } 1049 } else { 1050 $time = ''; 1051 } 1017 1052 1018 1053 /** 1019 1054 * Filters the returned comment time. … … 1020 1055 * 1021 1056 * @since 1.5.0 1022 1057 * 1023 * @param string|int $dateThe comment time, formatted as a date string or Unix timestamp.1024 * @param string $d Date format.1025 * @param bool $gmtWhether the GMT date is in use.1026 * @param bool $translateWhether the time is translated.1027 * @param WP_Comment $commentThe comment object.1058 * @param string|int $time The comment time, formatted as a date string or Unix timestamp. 1059 * @param string $time_format Time format. 1060 * @param bool $gmt Whether the GMT date is in use. 1061 * @param bool $translate Whether the time is translated. 1062 * @param WP_Comment|null $comment The comment object. 1028 1063 */ 1029 return apply_filters( 'get_comment_time', $ date, $d, $gmt, $translate, $comment );1064 return apply_filters( 'get_comment_time', $time, $time_format, $gmt, $translate, $comment ); 1030 1065 } 1031 1066 1032 1067 /** … … 1034 1069 * 1035 1070 * @since 0.71 1036 1071 * 1037 * @param string $ dOptional. The format of the time. Default user's settings.1072 * @param string $time_format Optional. The format of the time. Default user's settings. 1038 1073 */ 1039 function comment_time( $ d= '' ) {1040 echo get_comment_time( $d);1074 function comment_time( $time_format = '' ) { 1075 echo get_comment_time( $time_format ); 1041 1076 } 1042 1077 1043 1078 /** … … 1052 1087 */ 1053 1088 function get_comment_type( $comment_ID = 0 ) { 1054 1089 $comment = get_comment( $comment_ID ); 1055 if ( '' == $comment->comment_type )1056 $comment->comment_type = 'comment';1057 1090 1091 if ( $comment ) { 1092 $comment_type = ( $comment->comment_type ) ? $comment->comment_type : 'comment'; 1093 } else { 1094 $comment_type = ''; 1095 } 1096 1097 $comment_ID = ( $comment ) ? $comment->comment_ID : $comment_ID; 1098 1058 1099 /** 1059 1100 * Filters the returned comment type. 1060 1101 * … … 1061 1102 * @since 1.5.0 1062 1103 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. 1063 1104 * 1064 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.1065 * @param int 1066 * @param WP_Comment $comment The comment object.1105 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. 1106 * @param int $comment_ID The comment ID. 1107 * @param WP_Comment|null $comment The comment object. 1067 1108 */ 1068 return apply_filters( 'get_comment_type', $comment ->comment_type, $comment->comment_ID, $comment );1109 return apply_filters( 'get_comment_type', $comment_type, $comment_ID, $comment ); 1069 1110 } 1070 1111 1071 1112 /** … … 1609 1650 1610 1651 $comment = get_comment( $comment ); 1611 1652 1612 if ( empty( $post )) {1653 if ( ! $post && $comment ) { 1613 1654 $post = $comment->comment_post_ID; 1614 1655 } 1615 1656 … … 1624 1665 * 1625 1666 * @since 4.1.0 1626 1667 * 1627 * @param array $args Comment reply link arguments. See get_comment_reply_link()1628 * for more information on accepted arguments.1629 * @param WP_Comment $comment The object of the comment being replied to.1630 * @param WP_Post $post The WP_Post object.1668 * @param array $args Comment reply link arguments. See get_comment_reply_link() 1669 * for more information on accepted arguments. 1670 * @param WP_Comment|null $comment The object of the comment being replied to. 1671 * @param WP_Post $post The WP_Post object. 1631 1672 */ 1632 1673 $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); 1633 1674 … … 1636 1677 esc_url( wp_login_url( get_permalink() ) ), 1637 1678 $args['login_text'] 1638 1679 ); 1639 } else {1680 } elseif ( $comment ) { 1640 1681 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', 1641 1682 $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID 1642 1683 ); … … 1647 1688 esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), 1648 1689 $args['reply_text'] 1649 1690 ); 1691 } else { 1692 $link = ''; 1650 1693 } 1651 1694 1652 1695 /** … … 1654 1697 * 1655 1698 * @since 2.7.0 1656 1699 * 1657 * @param string $link The HTML markup for the comment reply link.1658 * @param array $args An array of arguments overriding the defaults.1659 * @param object $comment The object of the comment being replied.1660 * @param WP_Post $post The WP_Post object.1700 * @param string $link The HTML markup for the comment reply link. 1701 * @param array $args An array of arguments overriding the defaults. 1702 * @param WP_Comment|null $comment The object of the comment being replied to. 1703 * @param WP_Post $post The WP_Post object. 1661 1704 */ 1662 1705 return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post ); 1663 1706 } -
tests/phpunit/tests/comment/getCommentCount.php
1 1 <?php 2 2 3 /** 4 * @group comment 5 */ 3 6 class Tests_Get_Comment_Count extends WP_UnitTestCase { 4 7 5 8 public function test_get_comment_count() { -
tests/phpunit/tests/comment/getCommentExcerpt.php
1 1 <?php 2 2 3 /** 4 * @group comment 5 */ 3 6 class Tests_Get_Comment_Excerpt extends WP_UnitTestCase { 4 7 protected static $bacon_comment; 5 8 … … 23 26 $this->assertEquals( 20, count( explode( ' ', $excerpt ) ) ); 24 27 } 25 28 29 public function test_get_comment_excerpt_with_non_existing_id() { 30 $comment_id = self::factory()->comment->create( array( 31 'comment_content' => self::$bacon_comment 32 ) ); 33 34 $this->assertEquals( '', get_comment_excerpt( -1 ) ); 35 } 36 26 37 public function test_get_comment_excerpt_filtered() { 27 38 $comment_id = self::factory()->comment->create( array( 28 39 'comment_content' => self::$bacon_comment -
tests/phpunit/tests/comment/getCommentText.php
1 <?php 2 3 /** 4 * @group comment 5 */ 6 class Tests_Get_Comment_Text extends WP_UnitTestCase { 7 protected static $bacon_comment; 8 9 public static function setUpBeforeClass() { 10 parent::setUpBeforeClass(); 11 12 self::$bacon_comment = 'Bacon ipsum dolor amet porchetta capicola sirloin prosciutto brisket shankle jerky. Ham hock filet mignon boudin ground round, prosciutto alcatra spare ribs meatball turducken pork beef ribs ham beef. Bacon pastrami short loin, venison tri-tip ham short ribs doner swine. Tenderloin pig tongue pork jowl doner. Pork loin rump t-bone, beef strip steak flank drumstick tri-tip short loin capicola jowl. Cow filet mignon hamburger doner rump. Short loin jowl drumstick, tongue tail beef ribs pancetta flank brisket landjaeger chuck venison frankfurter turkey. 13 14 Brisket shank rump, tongue beef ribs swine fatback turducken capicola meatball picanha chicken cupim meatloaf turkey. Bacon biltong shoulder tail frankfurter boudin cupim turkey drumstick. Porchetta pig shoulder, jerky flank pork tail meatball hamburger. Doner ham hock ribeye tail jerky swine. Leberkas ribeye pancetta, tenderloin capicola doner turducken chicken venison ground round boudin pork chop. Tail pork loin pig spare ribs, biltong ribeye brisket pork chop cupim. Short loin leberkas spare ribs jowl landjaeger tongue kevin flank bacon prosciutto. 15 16 Shankle pork chop prosciutto ribeye ham hock pastrami. T-bone shank brisket bacon pork chop. Cupim hamburger pork loin short loin. Boudin ball tip cupim ground round ham shoulder. Sausage rump cow tongue bresaola pork pancetta biltong tail chicken turkey hamburger. Kevin flank pork loin salami biltong. Alcatra landjaeger pastrami andouille kielbasa ham tenderloin drumstick sausage turducken tongue corned beef.'; 17 } 18 19 public function test_get_comment_text() { 20 $comment_id = self::factory()->comment->create( array( 21 'comment_content' => self::$bacon_comment 22 ) ); 23 24 $this->assertEquals( self::$bacon_comment, get_comment_text( $comment_id ) ); 25 } 26 27 public function test_get_comment_text_with_non_existing_id() { 28 $comment_id = self::factory()->comment->create( array( 29 'comment_content' => self::$bacon_comment 30 ) ); 31 32 $this->assertEquals( '', get_comment_text( -1 ) ); 33 } 34 } -
tests/phpunit/tests/comment/metaCache.php
1 1 <?php 2 2 3 /** 4 * @group comment 5 */ 3 6 class Tests_Comment_Meta_Cache extends WP_UnitTestCase { 4 7 protected $i = 0; 5 8 protected $queries = 0; -
tests/phpunit/tests/comment/wpCountComments.php
1 1 <?php 2 2 3 /** 4 * @group comment 5 */ 3 6 class Tests_WP_Count_Comments extends WP_UnitTestCase { 4 7 5 8 public function test_wp_count_comments() {