Changeset 55660 for trunk/src/wp-includes/comment-template.php
- Timestamp:
- 04/19/2023 02:38:34 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-template.php
r55632 r55660 23 23 */ 24 24 function get_comment_author( $comment_id = 0 ) { 25 $comment = get_comment( $comment_id ); 25 $comment = get_comment( $comment_id ); 26 26 27 $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : $comment_id; 27 28 … … 29 30 $user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false; 30 31 if ( $user ) { 31 $ author = $user->display_name;32 $comment_author = $user->display_name; 32 33 } else { 33 $ author = __( 'Anonymous' );34 $comment_author = __( 'Anonymous' ); 34 35 } 35 36 } else { 36 $ author = $comment->comment_author;37 $comment_author = $comment->comment_author; 37 38 } 38 39 … … 43 44 * @since 4.1.0 The `$comment_id` and `$comment` parameters were added. 44 45 * 45 * @param string $ authorThe comment author's username.46 * @param string $comment_id The comment ID as a numeric string.47 * @param WP_Comment $comment The comment object.48 */ 49 return apply_filters( 'get_comment_author', $ author, $comment_id, $comment );46 * @param string $comment_author The comment author's username. 47 * @param string $comment_id The comment ID as a numeric string. 48 * @param WP_Comment $comment The comment object. 49 */ 50 return apply_filters( 'get_comment_author', $comment_author, $comment_id, $comment ); 50 51 } 51 52 … … 61 62 function comment_author( $comment_id = 0 ) { 62 63 $comment = get_comment( $comment_id ); 63 $author = get_comment_author( $comment ); 64 65 $comment_author = get_comment_author( $comment ); 64 66 65 67 /** … … 69 71 * @since 4.1.0 The `$comment_id` parameter was added. 70 72 * 71 * @param string $ authorThe comment author's username.72 * @param string $comment_id The comment ID as a numeric string.73 */ 74 echo apply_filters( 'comment_author', $ author, $comment->comment_ID );73 * @param string $comment_author The comment author's username. 74 * @param string $comment_id The comment ID as a numeric string. 75 */ 76 echo apply_filters( 'comment_author', $comment_author, $comment->comment_ID ); 75 77 } 76 78 … … 117 119 */ 118 120 function comment_author_email( $comment_id = 0 ) { 119 $comment = get_comment( $comment_id ); 120 $author_email = get_comment_author_email( $comment ); 121 $comment = get_comment( $comment_id ); 122 123 $comment_author_email = get_comment_author_email( $comment ); 121 124 122 125 /** … … 126 129 * @since 4.1.0 The `$comment_id` parameter was added. 127 130 * 128 * @param string $ author_email The comment author's email address.129 * @param string $comment_id The comment ID as a numeric string.130 */ 131 echo apply_filters( 'author_email', $ author_email, $comment->comment_ID );131 * @param string $comment_author_email The comment author's email address. 132 * @param string $comment_id The comment ID as a numeric string. 133 */ 134 echo apply_filters( 'author_email', $comment_author_email, $comment->comment_ID ); 132 135 } 133 136 … … 144 147 * @since 4.6.0 Added the `$comment` parameter. 145 148 * 146 * @param string $link text Optional. Text to display instead of the comment author's email address.147 * Default empty.148 * @param string $before Optional. Text or HTML to display before the email link. Default empty.149 * @param string $after Optional. Text or HTML to display after the email link. Default empty.150 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.151 */ 152 function comment_author_email_link( $link text = '', $before = '', $after = '', $comment = null ) {153 $link = get_comment_author_email_link( $link text, $before, $after, $comment );149 * @param string $link_text Optional. Text to display instead of the comment author's email address. 150 * Default empty. 151 * @param string $before Optional. Text or HTML to display before the email link. Default empty. 152 * @param string $after Optional. Text or HTML to display after the email link. Default empty. 153 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. 154 */ 155 function comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null ) { 156 $link = get_comment_author_email_link( $link_text, $before, $after, $comment ); 154 157 if ( $link ) { 155 158 echo $link; … … 169 172 * @since 4.6.0 Added the `$comment` parameter. 170 173 * 171 * @param string $link text Optional. Text to display instead of the comment author's email address.172 * Default empty.173 * @param string $before Optional. Text or HTML to display before the email link. Default empty.174 * @param string $after Optional. Text or HTML to display after the email link. Default empty.175 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment.174 * @param string $link_text Optional. Text to display instead of the comment author's email address. 175 * Default empty. 176 * @param string $before Optional. Text or HTML to display before the email link. Default empty. 177 * @param string $after Optional. Text or HTML to display after the email link. Default empty. 178 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. Default is the current comment. 176 179 * @return string HTML markup for the comment author email link. By default, the email address is obfuscated 177 180 * via the {@see 'comment_email'} filter with antispambot(). 178 181 */ 179 function get_comment_author_email_link( $link text = '', $before = '', $after = '', $comment = null ) {182 function get_comment_author_email_link( $link_text = '', $before = '', $after = '', $comment = null ) { 180 183 $comment = get_comment( $comment ); 181 184 … … 192 195 * @param WP_Comment $comment The comment object. 193 196 */ 194 $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); 195 196 if ( ( ! empty( $email ) ) && ( '@' !== $email ) ) { 197 $display = ( '' !== $linktext ) ? $linktext : $email; 198 $return = $before; 199 $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) ); 200 $return .= $after; 201 return $return; 197 $comment_author_email = apply_filters( 'comment_email', $comment->comment_author_email, $comment ); 198 199 if ( ( ! empty( $comment_author_email ) ) && ( '@' !== $comment_author_email ) ) { 200 $display = ( '' !== $link_text ) ? $link_text : $comment_author_email; 201 202 $comment_author_email_link = $before . sprintf( 203 '<a href="%1$s">%2$s</a>', 204 esc_url( 'mailto:' . $comment_author_email ), 205 esc_html( $display ) 206 ) . $after; 207 208 return $comment_author_email_link; 202 209 } else { 203 210 return ''; … … 219 226 */ 220 227 function get_comment_author_link( $comment_id = 0 ) { 221 $comment = get_comment( $comment_id ); 228 $comment = get_comment( $comment_id ); 229 222 230 $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : (string) $comment_id; 223 $url = get_comment_author_url( $comment ); 224 $author = get_comment_author( $comment ); 225 226 if ( empty( $url ) || 'http://' === $url ) { 227 $return = $author; 231 232 $comment_author_url = get_comment_author_url( $comment ); 233 $comment_author = get_comment_author( $comment ); 234 235 if ( empty( $comment_author_url ) || 'http://' === $comment_author_url ) { 236 $comment_author_link = $comment_author; 228 237 } else { 229 238 $rel_parts = array( 'ugc' ); 230 if ( ! wp_is_internal_link( $ url ) ) {239 if ( ! wp_is_internal_link( $comment_author_url ) ) { 231 240 $rel_parts = array_merge( 232 241 $rel_parts, … … 251 260 $rel = ! empty( $rel ) ? sprintf( ' rel="%s"', $rel ) : ''; 252 261 253 $ return= sprintf(262 $comment_author_link = sprintf( 254 263 '<a href="%1$s" class="url"%2$s>%3$s</a>', 255 $ url,264 $comment_author_url, 256 265 $rel, 257 $ author266 $comment_author 258 267 ); 259 268 } … … 263 272 * 264 273 * @since 1.5.0 265 * @since 4.1.0 The `$ author` and `$comment_id` parameters were added.266 * 267 * @param string $ returnThe HTML-formatted comment author link.268 * Empty for an invalid URL.269 * @param string $ authorThe comment author's username.270 * @param string $comment_id The comment ID as a numeric string.271 */ 272 return apply_filters( 'get_comment_author_link', $ return, $author, $comment_id );274 * @since 4.1.0 The `$comment_author` and `$comment_id` parameters were added. 275 * 276 * @param string $comment_author_link The HTML-formatted comment author link. 277 * Empty for an invalid URL. 278 * @param string $comment_author The comment author's username. 279 * @param string $comment_id The comment ID as a numeric string. 280 */ 281 return apply_filters( 'get_comment_author_link', $comment_author_link, $comment_author, $comment_id ); 273 282 } 274 283 … … 337 346 function get_comment_author_url( $comment_id = 0 ) { 338 347 $comment = get_comment( $comment_id ); 339 $url = ''; 340 $id = 0; 348 349 $comment_author_url = ''; 350 $comment_id = 0; 341 351 342 352 if ( ! empty( $comment ) ) { 343 $author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url; 344 $url = esc_url( $author_url, array( 'http', 'https' ) ); 345 $id = $comment->comment_ID; 353 $comment_author_url = ( 'http://' === $comment->comment_author_url ) ? '' : $comment->comment_author_url; 354 $comment_author_url = esc_url( $comment_author_url, array( 'http', 'https' ) ); 355 356 $comment_id = $comment->comment_ID; 346 357 } 347 358 … … 352 363 * @since 4.1.0 The `$comment_id` and `$comment` parameters were added. 353 364 * 354 * @param string $ urlThe comment author's URL, or an empty string.355 * @param string|int $comment_id The comment ID as a numeric string, or 0 if not found.356 * @param WP_Comment|null $comment The comment object, or null if not found.357 */ 358 return apply_filters( 'get_comment_author_url', $ url, $id, $comment );365 * @param string $comment_author_url The comment author's URL, or an empty string. 366 * @param string|int $comment_id The comment ID as a numeric string, or 0 if not found. 367 * @param WP_Comment|null $comment The comment object, or null if not found. 368 */ 369 return apply_filters( 'get_comment_author_url', $comment_author_url, $comment_id, $comment ); 359 370 } 360 371 … … 369 380 */ 370 381 function comment_author_url( $comment_id = 0 ) { 371 $comment = get_comment( $comment_id ); 372 $author_url = get_comment_author_url( $comment ); 382 $comment = get_comment( $comment_id ); 383 384 $comment_author_url = get_comment_author_url( $comment ); 373 385 374 386 /** … … 378 390 * @since 4.1.0 The `$comment_id` parameter was added. 379 391 * 380 * @param string $ author_url The comment author's URL.381 * @param string $comment_id The comment ID as a numeric string.382 */ 383 echo apply_filters( 'comment_url', $ author_url, $comment->comment_ID );392 * @param string $comment_author_url The comment author's URL. 393 * @param string $comment_id The comment ID as a numeric string. 394 */ 395 echo apply_filters( 'comment_url', $comment_author_url, $comment->comment_ID ); 384 396 } 385 397 … … 387 399 * Retrieves the HTML link of the URL of the author of the current comment. 388 400 * 389 * $link text parameter is only used if the URL does not exist for the comment390 * author. If the URL does exist then the URL will be used and the $link text401 * $link_text parameter is only used if the URL does not exist for the comment 402 * author. If the URL does exist then the URL will be used and the $link_text 391 403 * will be ignored. 392 404 * … … 397 409 * @since 4.6.0 Added the `$comment` parameter. 398 410 * 399 * @param string $link text Optional. The text to display instead of the comment400 * author's email address. Default empty.401 * @param string $before Optional. The text or HTML to display before the email link.402 * Default empty.403 * @param string $after Optional. The text or HTML to display after the email link.404 * Default empty.405 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object.406 * Default is the current comment.411 * @param string $link_text Optional. The text to display instead of the comment 412 * author's email address. Default empty. 413 * @param string $before Optional. The text or HTML to display before the email link. 414 * Default empty. 415 * @param string $after Optional. The text or HTML to display after the email link. 416 * Default empty. 417 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. 418 * Default is the current comment. 407 419 * @return string The HTML link between the $before and $after parameters. 408 420 */ 409 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { 410 $url = get_comment_author_url( $comment ); 411 $display = ( '' !== $linktext ) ? $linktext : $url; 421 function get_comment_author_url_link( $link_text = '', $before = '', $after = '', $comment = 0 ) { 422 $comment_author_url = get_comment_author_url( $comment ); 423 424 $display = ( '' !== $link_text ) ? $link_text : $comment_author_url; 412 425 $display = str_replace( 'http://www.', '', $display ); 413 426 $display = str_replace( 'http://', '', $display ); … … 417 430 } 418 431 419 $return = "$before<a href='$url' rel='external'>$display</a>$after"; 432 $comment_author_url_link = $before . sprintf( 433 '<a href="%1$s" rel="external">%2$s</a>', 434 $comment_author_url, 435 $display 436 ) . $after; 420 437 421 438 /** … … 424 441 * @since 1.5.0 425 442 * 426 * @param string $ returnThe HTML-formatted comment author URL link.427 */ 428 return apply_filters( 'get_comment_author_url_link', $ return);443 * @param string $comment_author_url_link The HTML-formatted comment author URL link. 444 */ 445 return apply_filters( 'get_comment_author_url_link', $comment_author_url_link ); 429 446 } 430 447 … … 435 452 * @since 4.6.0 Added the `$comment` parameter. 436 453 * 437 * @param string $link text Optional. Text to display instead of the comment author's438 * email address. Default empty.439 * @param string $before Optional. Text or HTML to display before the email link.440 * Default empty.441 * @param string $after Optional. Text or HTML to display after the email link.442 * Default empty.443 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object.444 * Default is the current comment.445 */ 446 function comment_author_url_link( $link text = '', $before = '', $after = '', $comment = 0 ) {447 echo get_comment_author_url_link( $link text, $before, $after, $comment );454 * @param string $link_text Optional. Text to display instead of the comment author's 455 * email address. Default empty. 456 * @param string $before Optional. Text or HTML to display before the email link. 457 * Default empty. 458 * @param string $after Optional. Text or HTML to display after the email link. 459 * Default empty. 460 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. 461 * Default is the current comment. 462 */ 463 function comment_author_url_link( $link_text = '', $before = '', $after = '', $comment = 0 ) { 464 echo get_comment_author_url_link( $link_text, $before, $after, $comment ); 448 465 } 449 466 … … 587 604 $_format = ! empty( $format ) ? $format : get_option( 'date_format' ); 588 605 589 $ date = mysql2date( $_format, $comment->comment_date );606 $comment_date = mysql2date( $_format, $comment->comment_date ); 590 607 591 608 /** … … 594 611 * @since 1.5.0 595 612 * 596 * @param string|int $ dateFormatted date string or Unix timestamp.597 * @param string $format PHP date format.598 * @param WP_Comment $comment The comment object.599 */ 600 return apply_filters( 'get_comment_date', $ date, $format, $comment );613 * @param string|int $comment_date Formatted date string or Unix timestamp. 614 * @param string $format PHP date format. 615 * @param WP_Comment $comment The comment object. 616 */ 617 return apply_filters( 'get_comment_date', $comment_date, $format, $comment ); 601 618 } 602 619 … … 648 665 $comment_excerpt_length = apply_filters( 'comment_excerpt_length', $comment_excerpt_length ); 649 666 650 $ excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' );667 $comment_excerpt = wp_trim_words( $comment_text, $comment_excerpt_length, '…' ); 651 668 652 669 /** … … 656 673 * @since 4.1.0 The `$comment_id` and `$comment` parameters were added. 657 674 * 658 * @param string $ excerptThe comment excerpt text.659 * @param string $comment_id The comment ID as a numeric string.660 * @param WP_Comment $comment The comment object.661 */ 662 return apply_filters( 'get_comment_excerpt', $ excerpt, $comment->comment_ID, $comment );675 * @param string $comment_excerpt The comment excerpt text. 676 * @param string $comment_id The comment ID as a numeric string. 677 * @param WP_Comment $comment The comment object. 678 */ 679 return apply_filters( 'get_comment_excerpt', $comment_excerpt, $comment->comment_ID, $comment ); 663 680 } 664 681 … … 673 690 */ 674 691 function comment_excerpt( $comment_id = 0 ) { 675 $comment = get_comment( $comment_id ); 692 $comment = get_comment( $comment_id ); 693 676 694 $comment_excerpt = get_comment_excerpt( $comment ); 677 695 … … 696 714 */ 697 715 function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid 698 $comment = get_comment(); 716 $comment = get_comment(); 717 699 718 $comment_id = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0'; 700 719 … … 762 781 'cpage' => null, 763 782 ); 764 $args = wp_parse_args( $args, $defaults ); 765 766 $link = get_permalink( $comment->comment_post_ID ); 783 784 $args = wp_parse_args( $args, $defaults ); 785 786 $comment_link = get_permalink( $comment->comment_post_ID ); 767 787 768 788 // The 'cpage' param takes precedence. … … 804 824 if ( $wp_rewrite->using_permalinks() ) { 805 825 if ( $cpage ) { 806 $ link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;826 $comment_link = trailingslashit( $comment_link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage; 807 827 } 808 828 809 $ link = user_trailingslashit( $link, 'comment' );829 $comment_link = user_trailingslashit( $comment_link, 'comment' ); 810 830 } elseif ( $cpage ) { 811 $ link = add_query_arg( 'cpage', $cpage, $link );831 $comment_link = add_query_arg( 'cpage', $cpage, $comment_link ); 812 832 } 813 833 } 814 834 815 835 if ( $wp_rewrite->using_permalinks() ) { 816 $ link = user_trailingslashit( $link, 'comment' );817 } 818 819 $ link = $link . '#comment-' . $comment->comment_ID;836 $comment_link = user_trailingslashit( $comment_link, 'comment' ); 837 } 838 839 $comment_link = $comment_link . '#comment-' . $comment->comment_ID; 820 840 821 841 /** … … 827 847 * @see get_page_of_comment() 828 848 * 829 * @param string $ linkThe comment permalink with '#comment-$id' appended.830 * @param WP_Comment $comment The current comment object.831 * @param array $args An array of arguments to override the defaults.832 * @param int $cpage The calculated 'cpage' value.833 */ 834 return apply_filters( 'get_comment_link', $ link, $comment, $args, $cpage );849 * @param string $comment_link The comment permalink with '#comment-$id' appended. 850 * @param WP_Comment $comment The current comment object. 851 * @param array $args An array of arguments to override the defaults. 852 * @param int $cpage The calculated 'cpage' value. 853 */ 854 return apply_filters( 'get_comment_link', $comment_link, $comment, $args, $cpage ); 835 855 } 836 856 … … 888 908 $post = get_post( $post ); 889 909 890 $co unt= $post ? $post->comment_count : 0;891 $post_id = $post ? $post->ID : 0;910 $comments_number = $post ? $post->comment_count : 0; 911 $post_id = $post ? $post->ID : 0; 892 912 893 913 /** … … 896 916 * @since 1.5.0 897 917 * 898 * @param string|int $co untA string representing the number of comments a post has, otherwise 0.918 * @param string|int $comments_number A string representing the number of comments a post has, otherwise 0. 899 919 * @param int $post_id Post ID. 900 920 */ 901 return apply_filters( 'get_comments_number', $co unt, $post_id );921 return apply_filters( 'get_comments_number', $comments_number, $post_id ); 902 922 } 903 923 … … 930 950 */ 931 951 function get_comments_number_text( $zero = false, $one = false, $more = false, $post = 0 ) { 932 $ number = get_comments_number( $post );933 934 if ( $ number > 1 ) {952 $comments_number = get_comments_number( $post ); 953 954 if ( $comments_number > 1 ) { 935 955 if ( false === $more ) { 936 /* translators: %s: Number of comments. */ 937 $output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) ); 956 $comments_number_text = sprintf( 957 /* translators: %s: Number of comments. */ 958 _n( '%s Comment', '%s Comments', $comments_number ), 959 number_format_i18n( $comments_number ) 960 ); 938 961 } else { 939 962 // % Comments … … 950 973 if ( $text && ! preg_match( '/[0-9]+/', $text ) && false !== strpos( $more, '%' ) ) { 951 974 /* translators: %s: Number of comments. */ 952 $new_text = _n( '%s Comment', '%s Comments', $ number );975 $new_text = _n( '%s Comment', '%s Comments', $comments_number ); 953 976 $new_text = trim( sprintf( $new_text, '' ) ); 954 977 … … 960 983 } 961 984 962 $ output = str_replace( '%', number_format_i18n( $number ), $more );985 $comments_number_text = str_replace( '%', number_format_i18n( $comments_number ), $more ); 963 986 } 964 } elseif ( 0 == $ number ) {965 $ output = ( false === $zero ) ? __( 'No Comments' ) : $zero;987 } elseif ( 0 == $comments_number ) { 988 $comments_number_text = ( false === $zero ) ? __( 'No Comments' ) : $zero; 966 989 } else { // Must be one. 967 $output = ( false === $one ) ? __( '1 Comment' ) : $one; 968 } 990 $comments_number_text = ( false === $one ) ? __( '1 Comment' ) : $one; 991 } 992 969 993 /** 970 994 * Filters the comments count for display. … … 974 998 * @see _n() 975 999 * 976 * @param string $ output A translatable string formatted based on whether the count977 * is equal to 0, 1, or 1+.978 * @param int $ numberThe number of post comments.979 */ 980 return apply_filters( 'comments_number', $ output, $number );1000 * @param string $comments_number_text A translatable string formatted based on whether the count 1001 * is equal to 0, 1, or 1+. 1002 * @param int $comments_number The number of post comments. 1003 */ 1004 return apply_filters( 'comments_number', $comments_number_text, $comments_number ); 981 1005 } 982 1006 … … 998 1022 $comment = get_comment( $comment_id ); 999 1023 1000 $comment_ content = $comment->comment_content;1024 $comment_text = $comment->comment_content; 1001 1025 1002 1026 if ( is_comment_feed() && $comment->comment_parent ) { … … 1006 1030 $name = get_comment_author( $parent ); 1007 1031 1008 $comment_ content = sprintf(1032 $comment_text = sprintf( 1009 1033 /* translators: %s: Comment link. */ 1010 1034 ent2ncr( __( 'In reply to %s.' ) ), 1011 1035 '<a href="' . $parent_link . '">' . $name . '</a>' 1012 ) . "\n\n" . $comment_ content;1036 ) . "\n\n" . $comment_text; 1013 1037 } 1014 1038 } … … 1021 1045 * @see Walker_Comment::comment() 1022 1046 * 1023 * @param string $comment_ content Text of the comment.1024 * @param WP_Comment $comment 1025 * @param array $args 1026 */ 1027 return apply_filters( 'get_comment_text', $comment_ content, $comment, $args );1047 * @param string $comment_text Text of the comment. 1048 * @param WP_Comment $comment The comment object. 1049 * @param array $args An array of arguments. 1050 */ 1051 return apply_filters( 'get_comment_text', $comment_text, $comment, $args ); 1028 1052 } 1029 1053 … … 1044 1068 1045 1069 $comment_text = get_comment_text( $comment, $args ); 1070 1046 1071 /** 1047 1072 * Filters the text of a comment to be displayed. … … 1051 1076 * @see Walker_Comment::comment() 1052 1077 * 1053 * @param string $comment_text Text of the c urrent comment.1078 * @param string $comment_text Text of the comment. 1054 1079 * @param WP_Comment|null $comment The comment object. Null if not found. 1055 1080 * @param array $args An array of arguments. … … 1083 1108 $_format = ! empty( $format ) ? $format : get_option( 'time_format' ); 1084 1109 1085 $ date = mysql2date( $_format, $comment_date, $translate );1110 $comment_time = mysql2date( $_format, $comment_date, $translate ); 1086 1111 1087 1112 /** … … 1090 1115 * @since 1.5.0 1091 1116 * 1092 * @param string|int $ dateThe comment time, formatted as a date string or Unix timestamp.1093 * @param string $format PHP date format.1094 * @param bool $gmt Whether the GMT date is in use.1095 * @param bool $translate Whether the time is translated.1096 * @param WP_Comment $comment The comment object.1097 */ 1098 return apply_filters( 'get_comment_time', $ date, $format, $gmt, $translate, $comment );1117 * @param string|int $comment_time The comment time, formatted as a date string or Unix timestamp. 1118 * @param string $format PHP date format. 1119 * @param bool $gmt Whether the GMT date is in use. 1120 * @param bool $translate Whether the time is translated. 1121 * @param WP_Comment $comment The comment object. 1122 */ 1123 return apply_filters( 'get_comment_time', $comment_time, $format, $gmt, $translate, $comment ); 1099 1124 } 1100 1125 … … 1279 1304 $_post = get_post( $post ); 1280 1305 1281 $post_id = $_post ? $_post->ID : 0;1282 $ open= ( $_post && ( 'open' === $_post->comment_status ) );1306 $post_id = $_post ? $_post->ID : 0; 1307 $comments_open = ( $_post && ( 'open' === $_post->comment_status ) ); 1283 1308 1284 1309 /** … … 1287 1312 * @since 2.5.0 1288 1313 * 1289 * @param bool $ openWhether the current post is open for comments.1290 * @param int $post_id The post ID.1291 */ 1292 return apply_filters( 'comments_open', $ open, $post_id );1314 * @param bool $comments_open Whether the current post is open for comments. 1315 * @param int $post_id The post ID. 1316 */ 1317 return apply_filters( 'comments_open', $comments_open, $post_id ); 1293 1318 } 1294 1319 … … 1308 1333 $_post = get_post( $post ); 1309 1334 1310 $post_id = $_post ? $_post->ID : 0;1311 $ open= ( $_post && ( 'open' === $_post->ping_status ) );1335 $post_id = $_post ? $_post->ID : 0; 1336 $pings_open = ( $_post && ( 'open' === $_post->ping_status ) ); 1312 1337 1313 1338 /** … … 1316 1341 * @since 2.5.0 1317 1342 * 1318 * @param bool $ openWhether the current post is open for pings.1319 * @param int $post_id The post ID.1320 */ 1321 return apply_filters( 'pings_open', $ open, $post_id );1343 * @param bool $pings_open Whether the current post is open for pings. 1344 * @param int $post_id The post ID. 1345 */ 1346 return apply_filters( 'pings_open', $pings_open, $post_id ); 1322 1347 } 1323 1348 … … 1609 1634 */ 1610 1635 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { 1611 $post_id = get_the_ID();1612 $post_title = get_the_title();1613 $ number= get_comments_number( $post_id );1636 $post_id = get_the_ID(); 1637 $post_title = get_the_title(); 1638 $comments_number = get_comments_number( $post_id ); 1614 1639 1615 1640 if ( false === $zero ) { … … 1625 1650 if ( false === $more ) { 1626 1651 /* translators: 1: Number of comments, 2: Post title. */ 1627 $more = _n( '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', $number ); 1628 $more = sprintf( $more, number_format_i18n( $number ), $post_title ); 1652 $more = _n( 1653 '%1$s Comment<span class="screen-reader-text"> on %2$s</span>', 1654 '%1$s Comments<span class="screen-reader-text"> on %2$s</span>', 1655 $comments_number 1656 ); 1657 $more = sprintf( $more, number_format_i18n( $comments_number ), $post_title ); 1629 1658 } 1630 1659 … … 1634 1663 } 1635 1664 1636 if ( 0 == $number && ! comments_open() && ! pings_open() ) { 1637 echo '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>'; 1665 if ( 0 == $comments_number && ! comments_open() && ! pings_open() ) { 1666 printf( 1667 '<span%1$s>%2$s</span>', 1668 ! empty( $css_class ) ? ' class="' . esc_attr( $css_class ) . '"' : '', 1669 $none 1670 ); 1638 1671 return; 1639 1672 } … … 1644 1677 } 1645 1678 1646 echo '<a href="'; 1647 if ( 0 == $number ) { 1679 if ( 0 == $comments_number ) { 1648 1680 $respond_link = get_permalink() . '#respond'; 1649 1681 /** … … 1655 1687 * @param int $post_id The post ID. 1656 1688 */ 1657 echoapply_filters( 'respond_link', $respond_link, $post_id );1689 $comments_link = apply_filters( 'respond_link', $respond_link, $post_id ); 1658 1690 } else { 1659 comments_link(); 1660 } 1661 echo '"'; 1662 1663 if ( ! empty( $css_class ) ) { 1664 echo ' class="' . $css_class . '" '; 1665 } 1666 1667 $attributes = ''; 1691 $comments_link = get_comments_link(); 1692 } 1693 1694 $link_attributes = ''; 1695 1668 1696 /** 1669 1697 * Filters the comments link attributes for display. … … 1671 1699 * @since 2.5.0 1672 1700 * 1673 * @param string $attributes The comments link attributes. Default empty. 1674 */ 1675 echo apply_filters( 'comments_popup_link_attributes', $attributes ); 1676 1677 echo '>'; 1678 comments_number( $zero, $one, $more ); 1679 echo '</a>'; 1701 * @param string $link_attributes The comments link attributes. Default empty. 1702 */ 1703 $link_attributes = apply_filters( 'comments_popup_link_attributes', $link_attributes ); 1704 1705 printf( 1706 '<a href="%1$s"%2$s%3$s>%4$s</a>', 1707 esc_url( $comments_link ), 1708 ! empty( $css_class ) ? ' class="' . $css_class . '" ' : '', 1709 $link_attributes, 1710 get_comments_number_text( $zero, $one, $more ) 1711 ); 1680 1712 } 1681 1713 … … 1803 1835 } 1804 1836 1837 $comment_reply_link = $args['before'] . $link . $args['after']; 1838 1805 1839 /** 1806 1840 * Filters the comment reply link. … … 1808 1842 * @since 2.7.0 1809 1843 * 1810 * @param string $ linkThe HTML markup for the comment reply link.1811 * @param array $args An array of arguments overriding the defaults.1812 * @param WP_Comment $comment The object of the comment being replied.1813 * @param WP_Post $post The WP_Post object.1814 */ 1815 return apply_filters( 'comment_reply_link', $ args['before'] . $link . $args['after'], $args, $comment, $post );1844 * @param string $comment_reply_link The HTML markup for the comment reply link. 1845 * @param array $args An array of arguments overriding the defaults. 1846 * @param WP_Comment $comment The object of the comment being replied. 1847 * @param WP_Post $post The WP_Post object. 1848 */ 1849 return apply_filters( 'comment_reply_link', $comment_reply_link, $args, $comment, $post ); 1816 1850 } 1817 1851 … … 1894 1928 ); 1895 1929 } 1896 $formatted_link = $args['before'] . $link . $args['after']; 1930 1931 $post_reply_link = $args['before'] . $link . $args['after']; 1897 1932 1898 1933 /** … … 1901 1936 * @since 2.7.0 1902 1937 * 1903 * @param string $ formattedThe HTML-formatted post comments link.1904 * @param int|WP_Post $post The post ID or WP_Post object.1905 */ 1906 return apply_filters( 'post_comments_link', $ formatted_link, $post );1938 * @param string $post_reply_link The HTML-formatted post comments link. 1939 * @param int|WP_Post $post The post ID or WP_Post object. 1940 */ 1941 return apply_filters( 'post_comments_link', $post_reply_link, $post ); 1907 1942 } 1908 1943 … … 1928 1963 * @since 6.2.0 Added the `$post` parameter. 1929 1964 * 1930 * @param string $ text Optional. Text to display for cancel reply link. If empty,1931 * defaults to 'Click here to cancel reply'. Default empty.1932 * @param int|WP_Post|null $post Optional. The post the comment thread is being1933 * displayed for. Defaults to the current global post.1965 * @param string $link_text Optional. Text to display for cancel reply link. If empty, 1966 * defaults to 'Click here to cancel reply'. Default empty. 1967 * @param int|WP_Post|null $post Optional. The post the comment thread is being 1968 * displayed for. Defaults to the current global post. 1934 1969 * @return string 1935 1970 */ 1936 function get_cancel_comment_reply_link( $ text = '', $post = null ) {1937 if ( empty( $ text ) ) {1938 $ text = __( 'Click here to cancel reply.' );1971 function get_cancel_comment_reply_link( $link_text = '', $post = null ) { 1972 if ( empty( $link_text ) ) { 1973 $link_text = __( 'Click here to cancel reply.' ); 1939 1974 } 1940 1975 1941 1976 $post = get_post( $post ); 1942 1977 $reply_to_id = $post ? _get_comment_reply_id( $post->ID ) : 0; 1943 $style = 0 !== $reply_to_id ? '' : ' style="display:none;"'; 1944 $link = esc_url( remove_query_arg( array( 'replytocom', 'unapproved', 'moderation-hash' ) ) ) . '#respond'; 1945 1946 $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; 1978 $link_style = 0 !== $reply_to_id ? '' : ' style="display:none;"'; 1979 $link_url = esc_url( remove_query_arg( array( 'replytocom', 'unapproved', 'moderation-hash' ) ) ) . '#respond'; 1980 1981 $cancel_comment_reply_link = sprintf( 1982 '<a rel="nofollow" id="cancel-comment-reply-link" href="%1$s"%2$s>%3$s</a>', 1983 $link_url, 1984 $link_style, 1985 $link_text 1986 ); 1947 1987 1948 1988 /** … … 1951 1991 * @since 2.7.0 1952 1992 * 1953 * @param string $ formatted_link The HTML-formatted cancel comment reply link.1954 * @param string $link Cancel comment reply link URL.1955 * @param string $ textCancel comment reply link text.1956 */ 1957 return apply_filters( 'cancel_comment_reply_link', $ formatted_link, $link, $text );1993 * @param string $cancel_comment_reply_link The HTML-formatted cancel comment reply link. 1994 * @param string $link_url Cancel comment reply link URL. 1995 * @param string $link_text Cancel comment reply link text. 1996 */ 1997 return apply_filters( 'cancel_comment_reply_link', $cancel_comment_reply_link, $link_url, $link_text ); 1958 1998 } 1959 1999 … … 1963 2003 * @since 2.7.0 1964 2004 * 1965 * @param string $ text Optional. Text to display for cancel reply link. If empty,2005 * @param string $link_text Optional. Text to display for cancel reply link. If empty, 1966 2006 * defaults to 'Click here to cancel reply'. Default empty. 1967 2007 */ 1968 function cancel_comment_reply_link( $ text = '' ) {1969 echo get_cancel_comment_reply_link( $ text );2008 function cancel_comment_reply_link( $link_text = '' ) { 2009 echo get_cancel_comment_reply_link( $link_text ); 1970 2010 } 1971 2011 … … 1988 2028 $post_id = $post->ID; 1989 2029 $reply_to_id = _get_comment_reply_id( $post_id ); 1990 $result = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n"; 1991 $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />\n"; 2030 2031 $comment_id_fields = "<input type='hidden' name='comment_post_ID' value='$post_id' id='comment_post_ID' />\n"; 2032 $comment_id_fields .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$reply_to_id' />\n"; 1992 2033 1993 2034 /** … … 1996 2037 * @since 3.0.0 1997 2038 * 1998 * @param string $ resultThe HTML-formatted hidden ID field comment elements.1999 * @param int $post_id The post ID.2000 * @param int $reply_to_id The ID of the comment being replied to.2001 */ 2002 return apply_filters( 'comment_id_fields', $ result, $post_id, $reply_to_id );2039 * @param string $comment_id_fields The HTML-formatted hidden ID field comment elements. 2040 * @param int $post_id The post ID. 2041 * @param int $reply_to_id The ID of the comment being replied to. 2042 */ 2043 return apply_filters( 'comment_id_fields', $comment_id_fields, $post_id, $reply_to_id ); 2003 2044 } 2004 2045 … … 2075 2116 2076 2117 if ( $link_to_parent ) { 2077 $author = '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $reply_to_id ) . '</a>'; 2118 $comment_author = sprintf( 2119 '<a href="#comment-%1$s">%2$s</a>', 2120 get_comment_ID(), 2121 get_comment_author( $reply_to_id ) 2122 ); 2078 2123 } else { 2079 $ author = get_comment_author( $reply_to_id );2080 } 2081 2082 printf( $reply_text, $ author );2124 $comment_author = get_comment_author( $reply_to_id ); 2125 } 2126 2127 printf( $reply_text, $comment_author ); 2083 2128 } 2084 2129
Note: See TracChangeset
for help on using the changeset viewer.