Ticket #25396: 25396.diff
File 25396.diff, 21.6 KB (added by , 11 years ago) |
---|
-
src/wp-includes/comment-template.php
31 31 $author = $comment->comment_author; 32 32 } 33 33 34 /** 35 * Filter the returned comment author name. 36 * 37 * @since 1.5.2 38 * 39 * @param string $author The comment author's username. 40 */ 34 41 return apply_filters( 'get_comment_author', $author ); 35 42 } 36 43 … … 42 49 * @param int $comment_ID Optional. The ID of the comment for which to print the author. Default current comment. 43 50 */ 44 51 function comment_author( $comment_ID = 0 ) { 45 $author = apply_filters('comment_author', get_comment_author( $comment_ID ) ); 52 $author = get_comment_author( $comment_ID ); 53 /** 54 * Filter the comment author's name for display. 55 * 56 * @since 1.2.1 57 * 58 * @param string $author The comment author's username. 59 */ 60 $author = apply_filters( 'comment_author', $author ); 46 61 echo $author; 47 62 } 48 63 … … 56 71 */ 57 72 function get_comment_author_email( $comment_ID = 0 ) { 58 73 $comment = get_comment( $comment_ID ); 59 return apply_filters('get_comment_author_email', $comment->comment_author_email); 74 /** 75 * Filter the comment author's returned email address. 76 * 77 * @since 1.5.2 78 * 79 * @param string $comment->comment_author_email The comment author's email address. 80 */ 81 return apply_filters( 'get_comment_author_email', $comment->comment_author_email ); 60 82 } 61 83 62 84 /** … … 73 95 * @param int $comment_ID Optional. The ID of the comment for which to print the author's email. Default current comment. 74 96 */ 75 97 function comment_author_email( $comment_ID = 0 ) { 76 echo apply_filters('author_email', get_comment_author_email( $comment_ID ) ); 98 $author_email = get_comment_author_email( $comment_ID ); 99 /** 100 * Filter the comment author's email for display. 101 * 102 * @since 1.2.1 103 * 104 * @param string $author_email The comment author's email address. 105 */ 106 echo apply_filters( 'author_email', $author_email ); 77 107 } 78 108 79 109 /** … … 117 147 */ 118 148 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) { 119 149 global $comment; 120 $email = apply_filters('comment_email', $comment->comment_author_email); 150 /** 151 * Filter the comment author's email for display. 152 * 153 * Care should be taken to protect the email address and assure that email 154 * harvesters do not capture your commentors' email address. 155 * 156 * @since 1.2.1 157 * 158 * @param string $comment->comment_author_email The comment author's email address. 159 */ 160 $email = apply_filters( 'comment_email', $comment->comment_author_email ); 121 161 if ((!empty($email)) && ($email != '@')) { 122 162 $display = ($linktext != '') ? $linktext : $email; 123 163 $return = $before; … … 148 188 $return = $author; 149 189 else 150 190 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; 151 return apply_filters('get_comment_author_link', $return); 191 192 /** 193 * Filter the comment author's link for display. 194 * 195 * @since 1.5.2 196 * 197 * @param string $return The HTML-formatted comment author link. Empty for an invalid URL. 198 */ 199 return apply_filters( 'get_comment_author_link', $return ); 152 200 } 153 201 154 202 /** … … 173 221 */ 174 222 function get_comment_author_IP( $comment_ID = 0 ) { 175 223 $comment = get_comment( $comment_ID ); 176 return apply_filters('get_comment_author_IP', $comment->comment_author_IP); 224 225 /** 226 * Filter the comment author's IP returned address. 227 * 228 * @since 1.5.2 229 * 230 * @param string $comment->comment_author_IP The comment author's IP address. 231 */ 232 return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP ); 177 233 } 178 234 179 235 /** … … 210 266 * @param int $comment_ID Optional. The ID of the comment for which to print the author's URL. Default current comment. 211 267 */ 212 268 function comment_author_url( $comment_ID = 0 ) { 213 echo apply_filters('comment_url', get_comment_author_url( $comment_ID )); 269 $author_url = get_comment_author_url( $comment_ID ); 270 /** 271 * Filter the comment author's URL for display. 272 * 273 * @since 1.2.1 274 * 275 * @param string $author_url The comment author's URL. 276 */ 277 echo apply_filters( 'comment_url', $author_url ); 214 278 } 215 279 216 280 /** … … 238 302 if ( '/' == substr($display, -1) ) 239 303 $display = substr($display, 0, -1); 240 304 $return = "$before<a href='$url' rel='external'>$display</a>$after"; 241 return apply_filters('get_comment_author_url_link', $return); 305 306 /** 307 * Filter the comment author's returned URL link. 308 * 309 * @since 1.5.2 310 * 311 * @param string $return The HTML-formatted comment author URL link. 312 */ 313 return apply_filters( 'get_comment_author_url_link', $return ); 242 314 } 243 315 244 316 /** … … 342 414 343 415 $classes = array_map('esc_attr', $classes); 344 416 345 return apply_filters('comment_class', $classes, $class, $comment_id, $post_id); 417 /** 418 * Filter the returned CSS classes for the current comment. 419 * 420 * @since 2.7.0 421 * 422 * @param array $classes An array of comment classes. 423 * @param string $class A comma-separated list of additional classes added to the list. 424 * @param int $comment_id The comment id. 425 * @param int|WP_Post $post_id The post ID or WP_Post object. 426 */ 427 return apply_filters( 'comment_class', $classes, $class, $comment_id, $post_id ); 346 428 } 347 429 348 430 /** … … 360 442 $date = mysql2date(get_option('date_format'), $comment->comment_date); 361 443 else 362 444 $date = mysql2date($d, $comment->comment_date); 363 return apply_filters('get_comment_date', $date, $d); 445 /** 446 * Filter the returned comment date. 447 * 448 * @since 1.5.2 449 * 450 * @param string|int $date Formatted date string or Unix timestamp. 451 * @param string $d The format of the date. 452 */ 453 return apply_filters( 'get_comment_date', $date, $d ); 364 454 } 365 455 366 456 /** … … 414 504 * @param int $comment_ID Optional. The ID of the comment for which to print the excerpt. Default current comment. 415 505 */ 416 506 function comment_excerpt( $comment_ID = 0 ) { 417 echo apply_filters('comment_excerpt', get_comment_excerpt($comment_ID) ); 507 $comment_excerpt = get_comment_excerpt($comment_ID); 508 /** 509 * Filter the comment excerpt for display. 510 * 511 * @since 1.2.1 512 * 513 * @param string $comment_excerpt The comment excerpt text. 514 */ 515 echo apply_filters( 'comment_excerpt', $comment_excerpt ); 418 516 } 419 517 420 518 /** … … 426 524 */ 427 525 function get_comment_ID() { 428 526 global $comment; 429 return apply_filters('get_comment_ID', $comment->comment_ID); 527 /** 528 * Filter the returned comment ID. 529 * 530 * @since 1.5.2 531 * 532 * @param int $comment->comment_ID The current comment ID. 533 */ 534 return apply_filters( 'get_comment_ID', $comment->comment_ID ); 430 535 } 431 536 432 537 /** … … 482 587 $link = get_permalink( $comment->comment_post_ID ); 483 588 } 484 589 485 return apply_filters( 'get_comment_link', $link . '#comment-' . $comment->comment_ID, $comment, $args ); 590 $link = $link . '#comment-' . $comment->comment_ID; 591 /** 592 * Filter the returned single comment permalink. 593 * 594 * @since 2.8.0 595 * 596 * @param string $link The comment permalink with '#comment-$id' appended. 597 * @param object $comment The current comment object. 598 * @param array $args An array of arguments to override the defaults. @see get_page_of_comment() 599 */ 600 return apply_filters( 'get_comment_link', $link, $comment, $args ); 486 601 } 487 602 488 603 /** … … 494 609 * @return string The link to the comments. 495 610 */ 496 611 function get_comments_link( $post_id = 0 ) { 497 return apply_filters( 'get_comments_link', get_permalink( $post_id ) . '#comments', $post_id ); 612 $comments_link = get_permalink( $post_id ) . '#comments'; 613 /** 614 * Filter the returned post comments permalink. 615 * 616 * @since 617 * 618 * @param string $comments_link The post comments permalink with '#comments' appended. 619 * @param int|WP_Post $post_id The post ID or WP_Post object. 620 */ 621 return apply_filters( 'get_comments_link', $comments_link, $post_id ); 498 622 } 499 623 500 624 /** … … 533 657 else 534 658 $count = $post->comment_count; 535 659 536 return apply_filters('get_comments_number', $count, $post_id); 660 /** 661 * Filter the returned comment count for a post. 662 * 663 * @since 1.5.2 664 * 665 * @param int $count The number of comments a post has. 666 * @param int|WP_Post $post_id The post ID or WP_Post object. 667 */ 668 return apply_filters( 'get_comments_number', $count, $post_id ); 537 669 } 538 670 539 671 /** … … 559 691 else // must be one 560 692 $output = ( false === $one ) ? __('1 Comment') : $one; 561 693 562 echo apply_filters('comments_number', $output, $number); 694 /** 695 * Filter the comments count for display. 696 * 697 * @since 1.5.2 698 * 699 * @param string $output A translatable string formatted based on whether the count is equal to 0, 1, or 1+. @see _n() 700 * @param int $number The number of post comments. 701 */ 702 echo apply_filters( 'comments_number', $output, $number ); 563 703 } 564 704 565 705 /** … … 629 769 $date = mysql2date(get_option('time_format'), $comment_date, $translate); 630 770 else 631 771 $date = mysql2date($d, $comment_date, $translate); 632 return apply_filters('get_comment_time', $date, $d, $gmt, $translate); 772 773 /** 774 * Filter the returned comment time. 775 * 776 * @since 1.5.2 777 * 778 * @param string|int $date Formatted date string or Unix timestamp. 779 * @param string $d The date format. 780 * @param bool $gmt Whether the GMT date is in use. 781 * @param bool $translate Whether the time is translated. 782 */ 783 return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate ); 633 784 } 634 785 635 786 /** … … 656 807 if ( '' == $comment->comment_type ) 657 808 $comment->comment_type = 'comment'; 658 809 659 return apply_filters('get_comment_type', $comment->comment_type); 810 /** 811 * Filter the returned comment type. 812 * 813 * @since 1.5.2 814 * 815 * @param string $comment->comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. 816 */ 817 return apply_filters( 'get_comment_type', $comment->comment_type ); 660 818 } 661 819 662 820 /** … … 697 855 * @return string The trackback URL after being filtered. 698 856 */ 699 857 function get_trackback_url() { 700 if ( '' != get_option('permalink_structure') ) {858 if ( '' != get_option('permalink_structure') ) 701 859 $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); 702 } else {860 else 703 861 $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID(); 704 } 705 return apply_filters('trackback_url', $tb_url); 862 863 /** 864 * Filter the returned trackback URL. 865 * 866 * @since 2.2.0 867 * 868 * @param string $tb_url The trackback URL. 869 */ 870 return apply_filters( 'trackback_url', $tb_url ); 706 871 } 707 872 708 873 /** … … 765 930 $_post = get_post($post_id); 766 931 767 932 $open = ( 'open' == $_post->comment_status ); 933 934 /** 935 * Filter whether the current post is open for comments. 936 * 937 * @since 938 * 939 * @param bool $open Whether the current post is open for comments. 940 * @param int|WP_Post $post_id The post ID or WP_Post object. 941 */ 768 942 return apply_filters( 'comments_open', $open, $post_id ); 769 943 } 770 944 … … 876 1050 } 877 1051 878 1052 // keep $comments for legacy's sake 1053 /** 1054 * Filter the comments array. 1055 * 1056 * @since 2.1.0 1057 * 1058 * @param array $comments The array of comments supplied to the comments template. 1059 * @param int $post->ID The post ID. 1060 */ 879 1061 $wp_query->comments = apply_filters( 'comments_array', $comments, $post->ID ); 880 1062 $comments = &$wp_query->comments; 881 1063 $wp_query->comment_count = count($wp_query->comments); … … 895 1077 if ( !defined('COMMENTS_TEMPLATE') ) 896 1078 define('COMMENTS_TEMPLATE', true); 897 1079 898 $include = apply_filters('comments_template', STYLESHEETPATH . $file ); 1080 $theme_template = STYLESHEETPATH . $file; 1081 /** 1082 * Filter the path to the theme template file used for the comments template. 1083 * 1084 * @since 1.5.2 1085 * 1086 * @param string $theme_template The path to the theme template file. 1087 */ 1088 $include = apply_filters( 'comments_template', $theme_template ); 899 1089 if ( file_exists( $include ) ) 900 1090 require( $include ); 901 1091 elseif ( file_exists( TEMPLATEPATH . $file ) ) … … 997 1187 } 998 1188 $title = the_title_attribute( array('echo' => 0 ) ); 999 1189 1000 echo apply_filters( 'comments_popup_link_attributes', '' ); 1190 $attributes = ''; 1191 /** 1192 * Filter the comments popup link attributes for display. 1193 * 1194 * @since 2.5.0 1195 * 1196 * @param string $attributes The comments popup link attributes. Default empty. 1197 */ 1198 echo apply_filters( 'comments_popup_link_attributes', $attributes ); 1001 1199 1002 1200 echo ' title="' . esc_attr( sprintf( __('Comment on %s'), $title ) ) . '">'; 1003 1201 comments_number( $zero, $one, $more ); … … 1130 1328 if ( !comments_open($post->ID) ) 1131 1329 return false; 1132 1330 1133 if ( get_option('comment_registration') && ! is_user_logged_in() ) {1331 if ( get_option('comment_registration') && ! is_user_logged_in() ) 1134 1332 $link = '<a rel="nofollow" href="' . wp_login_url( get_permalink() ) . '">' . $login_text . '</a>'; 1135 } else {1333 else 1136 1334 $link = "<a rel='nofollow' class='comment-reply-link' href='" . get_permalink($post->ID) . "#$respond_id' onclick='return addComment.moveForm(\"$add_below-$post->ID\", \"0\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>"; 1137 } 1138 return apply_filters('post_comments_link', $before . $link . $after, $post); 1335 1336 $formatted_link = $before . $link . $after; 1337 /** 1338 * Filter the formatted post comments link HTML. 1339 * 1340 * @since 2.7.0 1341 * 1342 * @param string $formatted The HTML-formatted post comments link. 1343 * @param int|WP_Post $post The post ID or WP_Post object. 1344 */ 1345 return apply_filters( 'post_comments_link', $formatted_link, $post ); 1139 1346 } 1140 1347 1141 1348 /** … … 1164 1371 1165 1372 $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"'; 1166 1373 $link = esc_html( remove_query_arg('replytocom') ) . '#respond'; 1167 return apply_filters('cancel_comment_reply_link', '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>', $link, $text); 1374 1375 $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>'; 1376 /** 1377 * Filter the cancel comment reply link HTML. 1378 * 1379 * @since 2.7.0 1380 * 1381 * @param string $formatted_link The HTML-formatted cancel comment reply link. 1382 * @param string $link The cancel comment reply link URL. 1383 * @param string $text The cancel comment reply link text. 1384 */ 1385 return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text ); 1168 1386 } 1169 1387 1170 1388 /** … … 1193 1411 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; 1194 1412 $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n"; 1195 1413 $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n"; 1196 return apply_filters('comment_id_fields', $result, $id, $replytoid); 1414 1415 /** 1416 * Filter the returned comment id fields. 1417 * 1418 * @since 3.0.0 1419 * 1420 * @param string $result The HTML-formatted hidden id field comment elements. 1421 * @param int $id The post ID. 1422 * @param int $replytoid The id of the comment being replied to. 1423 */ 1424 return apply_filters( 'comment_id_fields', $result, $id, $replytoid ); 1197 1425 } 1198 1426 1199 1427 /** … … 1695 1923 ); 1696 1924 1697 1925 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' ); 1926 1927 /** 1928 * Filter the default comment form fields. 1929 * 1930 * @since 3.0.0 1931 * 1932 * @param array $fields The default comment fields. 1933 */ 1934 $fields = apply_filters( 'comment_form_default_fields', $fields ); 1698 1935 $defaults = array( 1699 'fields' => apply_filters( 'comment_form_default_fields', $fields ),1936 'fields' => $fields, 1700 1937 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>', 1701 1938 'must_log_in' => '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', 1702 1939 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>', … … 1711 1948 'format' => 'xhtml', 1712 1949 ); 1713 1950 1951 /** 1952 * Filter the comment form default arguments. 1953 * 1954 * Use 'comment_form_default_fields' to filter the comment fields. 1955 * 1956 * @since 3.0.0 1957 * 1958 * @param array $defaults The default comment form arguments. 1959 */ 1714 1960 $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) ); 1715 1961 1716 1962 ?> 1717 1963 <?php if ( comments_open( $post_id ) ) : ?> 1718 <?php do_action( 'comment_form_before' ); ?> 1964 <?php 1965 /** 1966 * Fires before the comment form. 1967 * 1968 * @since 3.0.0 1969 */ 1970 do_action( 'comment_form_before' ); 1971 ?> 1719 1972 <div id="respond" class="comment-respond"> 1720 1973 <h3 id="reply-title" class="comment-reply-title"><?php comment_form_title( $args['title_reply'], $args['title_reply_to'] ); ?> <small><?php cancel_comment_reply_link( $args['cancel_reply_link'] ); ?></small></h3> 1721 1974 <?php if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : ?> 1722 1975 <?php echo $args['must_log_in']; ?> 1723 <?php do_action( 'comment_form_must_log_in_after' ); ?> 1976 <?php 1977 /** 1978 * Fires after the HTML-formatted 'must log in after' message in the comment form. 1979 * 1980 * @since 3.0.0 1981 */ 1982 do_action( 'comment_form_must_log_in_after' ); 1983 ?> 1724 1984 <?php else : ?> 1725 1985 <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="comment-form"<?php echo $html5 ? ' novalidate' : ''; ?>> 1726 <?php do_action( 'comment_form_top' ); ?> 1986 <?php 1987 /** 1988 * Fires at the top of the comment form, inside the <form> tag. 1989 * 1990 * @since 3.0.0 1991 */ 1992 do_action( 'comment_form_top' ); 1993 ?> 1727 1994 <?php if ( is_user_logged_in() ) : ?> 1728 <?php echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); ?> 1729 <?php do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); ?> 1995 <?php 1996 /** 1997 * Filter the 'logged in' message for the comment form for display. 1998 * 1999 * @since 3.0.0 2000 * 2001 * @param string $args['logged_in_as'] The logged-in-as HTML-formatted message. 2002 * @param array $commenter An array containing the comment author's username, email, and URL. 2003 * @param string $user_identity If the commenter is a registered user, the display name, blank otherwise. 2004 */ 2005 echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity ); 2006 ?> 2007 <?php 2008 /** 2009 * Fires after the is_user_logged_in() check in the comment form. 2010 * 2011 * @since 3.0.0 2012 * 2013 * @param array $commenter An array containing the comment author's username, email, and URL. 2014 * @param string $user_identity If the commenter is a registered user, the display name, blank otherwise. 2015 */ 2016 do_action( 'comment_form_logged_in_after', $commenter, $user_identity ); 2017 ?> 1730 2018 <?php else : ?> 1731 2019 <?php echo $args['comment_notes_before']; ?> 1732 2020 <?php 2021 /** 2022 * Fires before the comment fields in the comment form. 2023 * 2024 * @since 3.0.0 2025 */ 1733 2026 do_action( 'comment_form_before_fields' ); 1734 2027 foreach ( (array) $args['fields'] as $name => $field ) { 2028 /** 2029 * Filter a comment form field for display. 2030 * 2031 * The dynamic portion of the filter hook, $name, refers to the name 2032 * of the comment form field. Such as 'author', 'email', or 'url'. 2033 * 2034 * @since 3.0.0 2035 * 2036 * @param string $field The HTML-formatted output of the comment form field. 2037 */ 1735 2038 echo apply_filters( "comment_form_field_{$name}", $field ) . "\n"; 1736 2039 } 2040 /** 2041 * Fires after the comment fields in the comment form. 2042 * 2043 * @since 3.0.0 2044 */ 1737 2045 do_action( 'comment_form_after_fields' ); 1738 2046 ?> 1739 2047 <?php endif; ?> 1740 <?php echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); ?> 2048 <?php 2049 /** 2050 * Filter the content of the comment textarea field for display. 2051 * 2052 * @since 3.0.0 2053 * 2054 * @param string $args['comment_field'] The content of the comment textarea field. 2055 */ 2056 echo apply_filters( 'comment_form_field_comment', $args['comment_field'] ); 2057 ?> 1741 2058 <?php echo $args['comment_notes_after']; ?> 1742 2059 <p class="form-submit"> 1743 2060 <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" /> 1744 2061 <?php comment_id_fields( $post_id ); ?> 1745 2062 </p> 1746 <?php do_action( 'comment_form', $post_id ); ?> 2063 <?php 2064 /** 2065 * Fires at the bottom of the comment form, inside the closing </form> tag. 2066 * 2067 * @since 1.5.2 2068 * 2069 * @param int $post_id The post ID. 2070 */ 2071 do_action( 'comment_form', $post_id ); 2072 ?> 1747 2073 </form> 1748 2074 <?php endif; ?> 1749 2075 </div><!-- #respond --> 1750 <?php do_action( 'comment_form_after' ); ?> 1751 <?php else : ?> 1752 <?php do_action( 'comment_form_comments_closed' ); ?> 1753 <?php endif; ?> 1754 <?php 2076 <?php 2077 /** 2078 * Fires after the comment form. 2079 * 2080 * @since 3.0.0 2081 */ 2082 do_action( 'comment_form_after' ); 2083 else : 2084 /** 2085 * Fires after the comment form if comments are closed. 2086 * 2087 * @since 3.0.0 2088 */ 2089 do_action( 'comment_form_comments_closed' ); 2090 endif; 1755 2091 }