3 * Comment template functions
5 * These functions are meant to live inside of the WordPress loop.
12 * Retrieve the author of the current comment.
14 * If the comment has an empty comment_author field, then 'Anonymous' person is
18 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
20 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author.
21 * Default current comment.
22 * @return string The comment author
24 function get_comment_author( $comment_ID = 0 ) {
25 $comment = get_comment( $comment_ID );
27 if ( empty( $comment->comment_author ) ) {
28 if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
29 $author = $user->display_name;
31 $author = __('Anonymous');
33 $author = $comment->comment_author;
37 * Filter the returned comment author name.
40 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
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.
46 return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment );
50 * Displays the author of the current comment.
53 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
55 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author.
56 * Default current comment.
58 function comment_author( $comment_ID = 0 ) {
59 $comment = get_comment( $comment_ID );
60 $author = get_comment_author( $comment );
63 * Filter the comment author's name for display.
66 * @since 4.1.0 The `$comment_ID` parameter was added.
68 * @param string $author The comment author's username.
69 * @param int $comment_ID The comment ID.
71 echo apply_filters( 'comment_author', $author, $comment->comment_ID );
75 * Retrieve the email of the author of the current comment.
78 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
80 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's email.
81 * Default current comment.
82 * @return string The current comment author's email
84 function get_comment_author_email( $comment_ID = 0 ) {
85 $comment = get_comment( $comment_ID );
88 * Filter the comment author's returned email address.
91 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
93 * @param string $comment_author_email The comment author's email address.
94 * @param int $comment_ID The comment ID.
95 * @param WP_Comment $comment The comment object.
97 return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment );
101 * Display the email of the author of the current global $comment.
103 * Care should be taken to protect the email address and assure that email
104 * harvesters do not capture your commentors' email address. Most assume that
105 * their email address will not appear in raw form on the blog. Doing so will
106 * enable anyone, including those that people don't want to get the email
107 * address and use it for their own means good and bad.
110 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
112 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's email.
113 * Default current comment.
115 function comment_author_email( $comment_ID = 0 ) {
116 $comment = get_comment( $comment_ID );
117 $author_email = get_comment_author_email( $comment );
120 * Filter the comment author's email for display.
123 * @since 4.1.0 The `$comment_ID` parameter was added.
125 * @param string $author_email The comment author's email address.
126 * @param int $comment_ID The comment ID.
128 echo apply_filters( 'author_email', $author_email, $comment->comment_ID );
132 * Display the html email link to the author of the current comment.
134 * Care should be taken to protect the email address and assure that email
135 * harvesters do not capture your commentors' email address. Most assume that
136 * their email address will not appear in raw form on the blog. Doing so will
137 * enable anyone, including those that people don't want to get the email
138 * address and use it for their own means good and bad.
142 * @param string $linktext Optional. Text to display instead of the comment author's email address.
144 * @param string $before Optional. Text or HTML to display before the email link. Default empty.
145 * @param string $after Optional. Text or HTML to display after the email link. Default empty.
147 function comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
148 if ( $link = get_comment_author_email_link( $linktext, $before, $after ) )
153 * Return the html email link to the author of the current comment.
155 * Care should be taken to protect the email address and assure that email
156 * harvesters do not capture your commentors' email address. Most assume that
157 * their email address will not appear in raw form on the blog. Doing so will
158 * enable anyone, including those that people don't want to get the email
159 * address and use it for their own means good and bad.
163 * @param string $linktext Optional. Text to display instead of the comment author's email address.
165 * @param string $before Optional. Text or HTML to display before the email link. Default empty.
166 * @param string $after Optional. Text or HTML to display after the email link. Default empty.
169 function get_comment_author_email_link( $linktext = '', $before = '', $after = '' ) {
170 $comment = get_comment();
172 * Filter the comment author's email for display.
174 * Care should be taken to protect the email address and assure that email
175 * harvesters do not capture your commenter's email address.
178 * @since 4.1.0 The `$comment` parameter was added.
180 * @param string $comment_author_email The comment author's email address.
181 * @param WP_Comment $comment The comment object.
183 $email = apply_filters( 'comment_email', $comment->comment_author_email, $comment );
184 if ((!empty($email)) && ($email != '@')) {
185 $display = ($linktext != '') ? $linktext : $email;
187 $return .= sprintf( '<a href="%1$s">%2$s</a>', esc_url( 'mailto:' . $email ), esc_html( $display ) );
196 * Retrieve the HTML link to the URL of the author of the current comment.
198 * Both get_comment_author_url() and get_comment_author() rely on get_comment(),
199 * which falls back to the global comment variable if the $comment_ID argument is empty.
202 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
204 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link.
205 * Default current comment.
206 * @return string The comment author name or HTML link for author's URL.
208 function get_comment_author_link( $comment_ID = 0 ) {
209 $comment = get_comment( $comment_ID );
210 $url = get_comment_author_url( $comment );
211 $author = get_comment_author( $comment );
213 if ( empty( $url ) || 'http://' == $url )
216 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>";
219 * Filter the comment author's link for display.
222 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added.
224 * @param string $return The HTML-formatted comment author link.
225 * Empty for an invalid URL.
226 * @param string $author The comment author's username.
227 * @param int $comment_ID The comment ID.
229 return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID );
233 * Display the html link to the url of the author of the current comment.
236 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
238 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's link.
239 * Default current comment.
241 function comment_author_link( $comment_ID = 0 ) {
242 echo get_comment_author_link( $comment_ID );
246 * Retrieve the IP address of the author of the current comment.
249 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
251 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address.
252 * Default current comment.
253 * @return string Comment author's IP address.
255 function get_comment_author_IP( $comment_ID = 0 ) {
256 $comment = get_comment( $comment_ID );
259 * Filter the comment author's returned IP address.
262 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
264 * @param string $comment_author_IP The comment author's IP address.
265 * @param int $comment_ID The comment ID.
266 * @param WP_Comment $comment The comment object.
268 return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment );
272 * Display the IP address of the author of the current comment.
275 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
277 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's IP address.
278 * Default current comment.
280 function comment_author_IP( $comment_ID = 0 ) {
281 echo esc_html( get_comment_author_IP( $comment_ID ) );
285 * Retrieve the url of the author of the current comment.
288 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
290 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL.
291 * Default current comment.
292 * @return string Comment author URL.
294 function get_comment_author_url( $comment_ID = 0 ) {
295 $comment = get_comment( $comment_ID );
296 $url = ('http://' == $comment->comment_author_url) ? '' : $comment->comment_author_url;
297 $url = esc_url( $url, array('http', 'https') );
300 * Filter the comment author's URL.
303 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
305 * @param string $url The comment author's URL.
306 * @param int $comment_ID The comment ID.
307 * @param WP_Comment $comment The comment object.
309 return apply_filters( 'get_comment_author_url', $url, $comment->comment_ID, $comment );
313 * Display the url of the author of the current comment.
316 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
318 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to print the author's URL.
319 * Default current comment.
321 function comment_author_url( $comment_ID = 0 ) {
322 $comment = get_comment( $comment_ID );
323 $author_url = get_comment_author_url( $comment );
326 * Filter the comment author's URL for display.
329 * @since 4.1.0 The `$comment_ID` parameter was added.
331 * @param string $author_url The comment author's URL.
332 * @param int $comment_ID The comment ID.
334 echo apply_filters( 'comment_url', $author_url, $comment->comment_ID );
338 * Retrieves the HTML link of the url of the author of the current comment.
340 * $linktext parameter is only used if the URL does not exist for the comment
341 * author. If the URL does exist then the URL will be used and the $linktext
344 * Encapsulate the HTML link between the $before and $after. So it will appear
345 * in the order of $before, link, and finally $after.
349 * @param string $linktext Optional. The text to display instead of the comment
350 * author's email address. Default empty.
351 * @param string $before Optional. The text or HTML to display before the email link.
353 * @param string $after Optional. The text or HTML to display after the email link.
355 * @return string The HTML link between the $before and $after parameters.
357 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
358 $url = get_comment_author_url();
359 $display = ($linktext != '') ? $linktext : $url;
360 $display = str_replace( 'http://www.', '', $display );
361 $display = str_replace( 'http://', '', $display );
363 if ( '/' == substr($display, -1) ) {
364 $display = substr($display, 0, -1);
367 $return = "$before<a href='$url' rel='external'>$display</a>$after";
370 * Filter the comment author's returned URL link.
374 * @param string $return The HTML-formatted comment author URL link.
376 return apply_filters( 'get_comment_author_url_link', $return );
380 * Displays the HTML link of the url of the author of the current comment.
384 * @param string $linktext Optional. Text to display instead of the comment author's
385 * email address. Default empty.
386 * @param string $before Optional. Text or HTML to display before the email link.
388 * @param string $after Optional. Text or HTML to display after the email link.
391 function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
392 echo get_comment_author_url_link( $linktext, $before, $after );
396 * Generates semantic classes for each comment element.
399 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
401 * @param string|array $class Optional. One or more classes to add to the class list.
403 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment.
404 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
405 * @param bool $echo Optional. Whether to cho or return the output.
407 * @return string If `$echo` is false, the class will be returned. Void otherwise.
409 function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) {
410 // Separates classes with a single space, collates classes for comment DIV
411 $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"';
419 * Returns the classes for the comment div as an array.
422 * @since 4.4.0 Added the ability for `$comment_id` to also accept a WP_Comment object.
424 * @global int $comment_alt
425 * @global int $comment_depth
426 * @global int $comment_thread_alt
428 * @param string|array $class Optional. One or more classes to add to the class list. Default empty.
429 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment.
430 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
431 * @return array An array of classes.
433 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
434 global $comment_alt, $comment_depth, $comment_thread_alt;
438 $comment = get_comment( $comment_id );
443 // Get the comment type (comment, trackback),
444 $classes[] = ( empty( $comment->comment_type ) ) ? 'comment' : $comment->comment_type;
446 // Add classes for comment authors that are registered users.
447 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) {
448 $classes[] = 'byuser';
449 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id );
450 // For comment authors who are the author of the post
451 if ( $post = get_post($post_id) ) {
452 if ( $comment->user_id === $post->post_author ) {
453 $classes[] = 'bypostauthor';
458 if ( empty($comment_alt) )
460 if ( empty($comment_depth) )
462 if ( empty($comment_thread_alt) )
463 $comment_thread_alt = 0;
465 if ( $comment_alt % 2 ) {
474 // Alt for top-level comments
475 if ( 1 == $comment_depth ) {
476 if ( $comment_thread_alt % 2 ) {
477 $classes[] = 'thread-odd';
478 $classes[] = 'thread-alt';
480 $classes[] = 'thread-even';
482 $comment_thread_alt++;
485 $classes[] = "depth-$comment_depth";
487 if ( !empty($class) ) {
488 if ( !is_array( $class ) )
489 $class = preg_split('#\s+#', $class);
490 $classes = array_merge($classes, $class);
493 $classes = array_map('esc_attr', $classes);
496 * Filter the returned CSS classes for the current comment.
500 * @param array $classes An array of comment classes.
501 * @param string $class A comma-separated list of additional classes added to the list.
502 * @param int $comment_id The comment id.
503 * @param WP_Comment $comment The comment object.
504 * @param int|WP_Post $post_id The post ID or WP_Post object.
506 return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id );
510 * Retrieve the comment date of the current comment.
513 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
515 * @param string $d Optional. The format of the date. Default user's setting.
516 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the date.
517 * Default current comment.
518 * @return string The comment's date.
520 function get_comment_date( $d = '', $comment_ID = 0 ) {
521 $comment = get_comment( $comment_ID );
523 $date = mysql2date(get_option('date_format'), $comment->comment_date);
525 $date = mysql2date($d, $comment->comment_date);
527 * Filter the returned comment date.
531 * @param string|int $date Formatted date string or Unix timestamp.
532 * @param string $d The format of the date.
533 * @param WP_Comment $comment The comment object.
535 return apply_filters( 'get_comment_date', $date, $d, $comment );
539 * Display the comment date of the current comment.
542 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
544 * @param string $d Optional. The format of the date. Default user's settings.
545 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the date.
546 * Default current comment.
548 function comment_date( $d = '', $comment_ID = 0 ) {
549 echo get_comment_date( $d, $comment_ID );
553 * Retrieve the excerpt of the current comment.
555 * Will cut each word and only output the first 20 words with '…' at the end.
556 * If the word count is less than 20, then no truncating is done and no '…'
560 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
562 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt.
563 * Default current comment.
564 * @return string The maybe truncated comment with 20 words or less.
566 function get_comment_excerpt( $comment_ID = 0 ) {
567 $comment = get_comment( $comment_ID );
568 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) );
569 $words = explode( ' ', $comment_text );
572 * Filter the amount of words used in the comment excerpt.
576 * @param int $comment_excerpt_length The amount of words you want to display in the comment excerpt.
578 $comment_excerpt_length = apply_filters( 'comment_excerpt_length', 20 );
580 $use_ellipsis = count( $words ) > $comment_excerpt_length;
581 if ( $use_ellipsis ) {
582 $words = array_slice( $words, 0, $comment_excerpt_length );
585 $excerpt = trim( join( ' ', $words ) );
586 if ( $use_ellipsis ) {
587 $excerpt .= '…';
590 * Filter the retrieved comment excerpt.
593 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
595 * @param string $excerpt The comment excerpt text.
596 * @param int $comment_ID The comment ID.
597 * @param WP_Comment $comment The comment object.
599 return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment );
603 * Display the excerpt of the current comment.
606 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
608 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the excerpt.
609 * Default current comment.
611 function comment_excerpt( $comment_ID = 0 ) {
612 $comment = get_comment( $comment_ID );
613 $comment_excerpt = get_comment_excerpt( $comment );
616 * Filter the comment excerpt for display.
619 * @since 4.1.0 The `$comment_ID` parameter was added.
621 * @param string $comment_excerpt The comment excerpt text.
622 * @param int $comment_ID The comment ID.
624 echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID );
628 * Retrieve the comment id of the current comment.
632 * @return int The comment ID.
634 function get_comment_ID() {
635 $comment = get_comment();
638 * Filter the returned comment ID.
641 * @since 4.1.0 The `$comment_ID` parameter was added.
643 * @param int $comment_ID The current comment ID.
644 * @param WP_Comment $comment The comment object.
646 return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment );
650 * Display the comment id of the current comment.
654 function comment_ID() {
655 echo get_comment_ID();
659 * Retrieve the link to a given comment.
662 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. Added `$cpage` argument.
664 * @see get_page_of_comment()
666 * @global WP_Rewrite $wp_rewrite
667 * @global bool $in_comment_loop
669 * @param WP_Comment|int|null $comment Comment to retrieve. Default current comment.
670 * @param array $args {
671 * An array of optional arguments to override the defaults.
673 * @type string $type Passed to {@see get_page_of_comment()}.
674 * @type int $page Current page of comments, for calculating comment pagination.
675 * @type int $per_page Per-page value for comment pagination.
676 * @type int $max_depth Passed to {@see get_page_of_comment()}.
677 * @type int|string $cpage Value to use for the comment's "comment-page" or "cpage" value. If provided, this
678 * value overrides any value calculated from `$page` and `$per_page`.
680 * @return string The permalink to the given comment.
682 function get_comment_link( $comment = null, $args = array() ) {
683 global $wp_rewrite, $in_comment_loop;
685 $comment = get_comment($comment);
688 if ( ! is_array( $args ) ) {
689 $args = array( 'page' => $args );
699 $args = wp_parse_args( $args, $defaults );
701 $link = get_permalink( $comment->comment_post_ID );
703 // The 'cpage' param takes precedence.
704 if ( ! is_null( $args['cpage'] ) ) {
705 $cpage = $args['cpage'];
707 // No 'cpage' is provided, so we calculate one.
709 if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) {
710 $args['per_page'] = get_option('comments_per_page');
713 if ( empty( $args['per_page'] ) ) {
714 $args['per_page'] = 0;
718 $cpage = $args['page'];
720 if ( '' == $cpage ) {
721 if ( ! empty( $in_comment_loop ) ) {
722 $cpage = get_query_var( 'cpage' );
724 // Requires a database hit, so we only do it when we can't figure out from context.
725 $cpage = get_page_of_comment( $comment->comment_ID, $args );
730 * If the default page displays the oldest comments, the permalinks for comments on the default page
731 * do not need a 'cpage' query var.
733 $default_comments_page = get_option( 'default_comments_page' );
734 if ( 'oldest' === get_option( 'default_comments_page' ) && 1 === $cpage ) {
739 if ( $cpage && get_option( 'page_comments' ) ) {
740 if ( $wp_rewrite->using_permalinks() ) {
742 $link = trailingslashit( $link ) . $wp_rewrite->comments_pagination_base . '-' . $cpage;
745 $link = user_trailingslashit( $link, 'comment' );
746 } elseif ( $cpage ) {
747 $link = add_query_arg( 'cpage', $cpage, $link );
752 if ( $wp_rewrite->using_permalinks() ) {
753 $link = user_trailingslashit( $link, 'comment' );
756 $link = $link . '#comment-' . $comment->comment_ID;
759 * Filter the returned single comment permalink.
762 * @since 4.4.0 Added the `$cpage` parameter.
764 * @see get_page_of_comment()
766 * @param string $link The comment permalink with '#comment-$id' appended.
767 * @param WP_Comment $comment The current comment object.
768 * @param array $args An array of arguments to override the defaults.
769 * @param int $cpage The calculated 'cpage' value.
771 return apply_filters( 'get_comment_link', $link, $comment, $args, $cpage );
775 * Retrieves the link to the current post comments.
779 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
780 * @return string The link to the comments.
782 function get_comments_link( $post_id = 0 ) {
783 $hash = get_comments_number( $post_id ) ? '#comments' : '#respond';
784 $comments_link = get_permalink( $post_id ) . $hash;
787 * Filter the returned post comments permalink.
791 * @param string $comments_link Post comments permalink with '#comments' appended.
792 * @param int|WP_Post $post_id Post ID or WP_Post object.
794 return apply_filters( 'get_comments_link', $comments_link, $post_id );
798 * Display the link to the current post comments.
802 * @param string $deprecated Not Used.
803 * @param string $deprecated_2 Not Used.
805 function comments_link( $deprecated = '', $deprecated_2 = '' ) {
806 if ( !empty( $deprecated ) )
807 _deprecated_argument( __FUNCTION__, '0.72' );
808 if ( !empty( $deprecated_2 ) )
809 _deprecated_argument( __FUNCTION__, '1.3' );
810 echo esc_url( get_comments_link() );
814 * Retrieve the amount of comments a post has.
818 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
819 * @return int The number of comments a post has.
821 function get_comments_number( $post_id = 0 ) {
822 $post = get_post( $post_id );
827 $count = $post->comment_count;
828 $post_id = $post->ID;
832 * Filter the returned comment count for a post.
836 * @param int $count Number of comments a post has.
837 * @param int $post_id Post ID.
839 return apply_filters( 'get_comments_number', $count, $post_id );
843 * Display the language string for the number of comments the current post has.
847 * @param string $zero Optional. Text for no comments. Default false.
848 * @param string $one Optional. Text for one comment. Default false.
849 * @param string $more Optional. Text for more than one comment. Default false.
850 * @param string $deprecated Not used.
852 function comments_number( $zero = false, $one = false, $more = false, $deprecated = '' ) {
853 if ( ! empty( $deprecated ) ) {
854 _deprecated_argument( __FUNCTION__, '1.3' );
856 echo get_comments_number_text( $zero, $one, $more );
860 * Display the language string for the number of comments the current post has.
864 * @param string $zero Optional. Text for no comments. Default false.
865 * @param string $one Optional. Text for one comment. Default false.
866 * @param string $more Optional. Text for more than one comment. Default false.
868 function get_comments_number_text( $zero = false, $one = false, $more = false ) {
869 $number = get_comments_number();
872 if ( false === $more ) {
873 /* translators: %s: number of comments */
874 $output = sprintf( _n( '%s Comment', '%s Comments', $number ), number_format_i18n( $number ) );
877 $output = str_replace( '%', number_format_i18n( $number ), $more );
879 } elseif ( $number == 0 ) {
880 $output = ( false === $zero ) ? __( 'No Comments' ) : $zero;
881 } else { // must be one
882 $output = ( false === $one ) ? __( '1 Comment' ) : $one;
885 * Filter the comments count for display.
891 * @param string $output A translatable string formatted based on whether the count
892 * is equal to 0, 1, or 1+.
893 * @param int $number The number of post comments.
895 return apply_filters( 'comments_number', $output, $number );
899 * Retrieve the text of the current comment.
902 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
904 * @see Walker_Comment::comment()
906 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the text.
907 * Default current comment.
908 * @param array $args Optional. An array of arguments. Default empty.
909 * @return string The comment content.
911 function get_comment_text( $comment_ID = 0, $args = array() ) {
912 $comment = get_comment( $comment_ID );
915 * Filter the text of a comment.
919 * @see Walker_Comment::comment()
921 * @param string $comment_content Text of the comment.
922 * @param WP_Comment $comment The comment object.
923 * @param array $args An array of arguments.
925 return apply_filters( 'get_comment_text', $comment->comment_content, $comment, $args );
929 * Display the text of the current comment.
932 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
934 * @see Walker_Comment::comment()
936 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to print the text.
937 * Default current comment.
938 * @param array $args Optional. An array of arguments. Default empty array. Default empty.
940 function comment_text( $comment_ID = 0, $args = array() ) {
941 $comment = get_comment( $comment_ID );
943 $comment_text = get_comment_text( $comment, $args );
945 * Filter the text of a comment to be displayed.
949 * @see Walker_Comment::comment()
951 * @param string $comment_text Text of the current comment.
952 * @param WP_Comment $comment The comment object.
953 * @param array $args An array of arguments.
955 echo apply_filters( 'comment_text', $comment_text, $comment, $args );
959 * Retrieve the comment time of the current comment.
963 * @param string $d Optional. The format of the time. Default user's settings.
964 * @param bool $gmt Optional. Whether to use the GMT date. Default false.
965 * @param bool $translate Optional. Whether to translate the time (for use in feeds).
967 * @return string The formatted time.
969 function get_comment_time( $d = '', $gmt = false, $translate = true ) {
970 $comment = get_comment();
972 $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
974 $date = mysql2date(get_option('time_format'), $comment_date, $translate);
976 $date = mysql2date($d, $comment_date, $translate);
979 * Filter the returned comment time.
983 * @param string|int $date The comment time, formatted as a date string or Unix timestamp.
984 * @param string $d Date format.
985 * @param bool $gmt Whether the GMT date is in use.
986 * @param bool $translate Whether the time is translated.
987 * @param WP_Comment $comment The comment object.
989 return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
993 * Display the comment time of the current comment.
997 * @param string $d Optional. The format of the time. Default user's settings.
999 function comment_time( $d = '' ) {
1000 echo get_comment_time($d);
1004 * Retrieve the comment type of the current comment.
1007 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object.
1009 * @param int|WP_Comment $comment_ID Optional. WP_Comment or ID of the comment for which to get the type.
1010 * Default current comment.
1011 * @return string The comment type.
1013 function get_comment_type( $comment_ID = 0 ) {
1014 $comment = get_comment( $comment_ID );
1015 if ( '' == $comment->comment_type )
1016 $comment->comment_type = 'comment';
1019 * Filter the returned comment type.
1022 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added.
1024 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'.
1025 * @param int $comment_ID The comment ID.
1026 * @param WP_Comment $comment The comment object.
1028 return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment );
1032 * Display the comment type of the current comment.
1036 * @param string $commenttxt Optional. String to display for comment type. Default false.
1037 * @param string $trackbacktxt Optional. String to display for trackback type. Default false.
1038 * @param string $pingbacktxt Optional. String to display for pingback type. Default false.
1040 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) {
1041 if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' );
1042 if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' );
1043 if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' );
1044 $type = get_comment_type();
1058 * Retrieve The current post's trackback URL.
1060 * There is a check to see if permalink's have been enabled and if so, will
1061 * retrieve the pretty path. If permalinks weren't enabled, the ID of the
1062 * current post is used and appended to the correct page to go to.
1066 * @return string The trackback URL after being filtered.
1068 function get_trackback_url() {
1069 if ( '' != get_option('permalink_structure') )
1070 $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback');
1072 $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . get_the_ID();
1075 * Filter the returned trackback URL.
1079 * @param string $tb_url The trackback URL.
1081 return apply_filters( 'trackback_url', $tb_url );
1085 * Display the current post's trackback URL.
1089 * @param bool $deprecated_echo Not used.
1090 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url()
1091 * for the result instead.
1093 function trackback_url( $deprecated_echo = true ) {
1094 if ( true !== $deprecated_echo ) {
1095 _deprecated_argument( __FUNCTION__, '2.5',
1096 /* translators: %s: get_trackback_url() */
1097 sprintf( __( 'Use %s instead if you do not want the value echoed.' ),
1098 '<code>get_trackback_url()</code>'
1103 if ( $deprecated_echo ) {
1104 echo get_trackback_url();
1106 return get_trackback_url();
1111 * Generate and display the RDF for the trackback information of current post.
1113 * Deprecated in 3.0.0, and restored in 3.0.1.
1117 * @param int $deprecated Not used (Was $timezone = 0).
1119 function trackback_rdf( $deprecated = '' ) {
1120 if ( ! empty( $deprecated ) ) {
1121 _deprecated_argument( __FUNCTION__, '2.5' );
1124 if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'W3C_Validator' ) ) {
1128 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
1129 xmlns:dc="http://purl.org/dc/elements/1.1/"
1130 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
1131 <rdf:Description rdf:about="';
1134 echo ' dc:identifier="';
1137 echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n";
1138 echo ' trackback:ping="'.get_trackback_url().'"'." />\n";
1143 * Whether the current post is open for comments.
1147 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
1148 * @return bool True if the comments are open.
1150 function comments_open( $post_id = null ) {
1152 $_post = get_post($post_id);
1154 $open = ( 'open' == $_post->comment_status );
1157 * Filter whether the current post is open for comments.
1161 * @param bool $open Whether the current post is open for comments.
1162 * @param int|WP_Post $post_id The post ID or WP_Post object.
1164 return apply_filters( 'comments_open', $open, $post_id );
1168 * Whether the current post is open for pings.
1172 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post.
1173 * @return bool True if pings are accepted
1175 function pings_open( $post_id = null ) {
1177 $_post = get_post($post_id);
1179 $open = ( 'open' == $_post->ping_status );
1182 * Filter whether the current post is open for pings.
1186 * @param bool $open Whether the current post is open for pings.
1187 * @param int|WP_Post $post_id The post ID or WP_Post object.
1189 return apply_filters( 'pings_open', $open, $post_id );
1193 * Display form token for unfiltered comments.
1195 * Will only display nonce token if the current user has permissions for
1196 * unfiltered html. Won't display the token for other users.
1198 * The function was backported to 2.0.10 and was added to versions 2.1.3 and
1199 * above. Does not exist in versions prior to 2.0.10 in the 2.0 branch and in
1200 * the 2.1 branch, prior to 2.1.3. Technically added in 2.2.0.
1202 * Backported to 2.0.10.
1206 function wp_comment_form_unfiltered_html_nonce() {
1208 $post_id = $post ? $post->ID : 0;
1210 if ( current_user_can( 'unfiltered_html' ) ) {
1211 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false );
1212 echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n";
1217 * Load the comment template specified in $file.
1219 * Will not display the comments template if not on single post or page, or if
1220 * the post does not have comments.
1222 * Uses the WordPress database object to query for the comments. The comments
1223 * are passed through the 'comments_array' filter hook with the list of comments
1224 * and the post ID respectively.
1226 * The $file path is passed through a filter hook called, 'comments_template'
1227 * which includes the TEMPLATEPATH and $file combined. Tries the $filtered path
1228 * first and if it fails it will require the default comment template from the
1229 * default theme. If either does not exist, then the WordPress process will be
1230 * halted. It is advised for that reason, that the default theme is not deleted.
1232 * @uses $withcomments Will not try to get the comments if the post has none.
1236 * @global WP_Query $wp_query
1237 * @global WP_Post $post
1238 * @global wpdb $wpdb
1240 * @global WP_Comment $comment
1241 * @global string $user_login
1242 * @global int $user_ID
1243 * @global string $user_identity
1244 * @global bool $overridden_cpage
1246 * @param string $file Optional. The file to load. Default '/comments.php'.
1247 * @param bool $separate_comments Optional. Whether to separate the comments by comment type.
1250 function comments_template( $file = '/comments.php', $separate_comments = false ) {
1251 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage;
1253 if ( !(is_single() || is_page() || $withcomments) || empty($post) )
1257 $file = '/comments.php';
1259 $req = get_option('require_name_email');
1262 * Comment author information fetched from the comment cookies.
1264 $commenter = wp_get_current_commenter();
1267 * The name of the current comment author escaped for use in attributes.
1268 * Escaped by sanitize_comment_cookies().
1270 $comment_author = $commenter['comment_author'];
1273 * The email address of the current comment author escaped for use in attributes.
1274 * Escaped by sanitize_comment_cookies().
1276 $comment_author_email = $commenter['comment_author_email'];
1279 * The url of the current comment author escaped for use in attributes.
1281 $comment_author_url = esc_url($commenter['comment_author_url']);
1283 $comment_args = array(
1284 'orderby' => 'comment_date_gmt',
1286 'status' => 'approve',
1287 'post_id' => $post->ID,
1288 'no_found_rows' => false,
1289 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance.
1292 if ( get_option('thread_comments') ) {
1293 $comment_args['hierarchical'] = 'threaded';
1295 $comment_args['hierarchical'] = false;
1299 $comment_args['include_unapproved'] = array( $user_ID );
1300 } elseif ( ! empty( $comment_author_email ) ) {
1301 $comment_args['include_unapproved'] = array( $comment_author_email );
1305 if ( get_option( 'page_comments' ) ) {
1306 $per_page = (int) get_query_var( 'comments_per_page' );
1307 if ( 0 === $per_page ) {
1308 $per_page = (int) get_option( 'comments_per_page' );
1311 $comment_args['number'] = $per_page;
1312 $page = (int) get_query_var( 'cpage' );
1315 $comment_args['offset'] = ( $page - 1 ) * $per_page;
1316 } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) {
1317 $comment_args['offset'] = 0;
1319 // If fetching the first page of 'newest', we need a top-level comment count.
1320 $top_level_query = new WP_Comment_Query();
1321 $top_level_args = array(
1324 'post_id' => $post->ID,
1325 'status' => 'approve',
1328 if ( $comment_args['hierarchical'] ) {
1329 $top_level_args['parent'] = 0;
1332 if ( isset( $comment_args['include_unapproved'] ) ) {
1333 $top_level_args['include_unapproved'] = $comment_args['include_unapproved'];
1336 $top_level_count = $top_level_query->query( $top_level_args );
1338 $comment_args['offset'] = ( ceil( $top_level_count / $per_page ) - 1 ) * $per_page;
1342 $comment_query = new WP_Comment_Query( $comment_args );
1343 $_comments = $comment_query->comments;
1345 // Trees must be flattened before they're passed to the walker.
1346 if ( $comment_args['hierarchical'] ) {
1347 $comments_flat = array();
1348 foreach ( $_comments as $_comment ) {
1349 $comments_flat[] = $_comment;
1350 $comment_children = $_comment->get_children( array(
1352 'status' => $comment_args['status'],
1353 'orderby' => $comment_args['orderby']
1356 foreach ( $comment_children as $comment_child ) {
1357 $comments_flat[] = $comment_child;
1361 $comments_flat = $_comments;
1365 * Filter the comments array.
1369 * @param array $comments Array of comments supplied to the comments template.
1370 * @param int $post_ID Post ID.
1372 $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID );
1374 // Set up lazy-loading for comment metadata.
1375 add_action( 'get_comment_metadata', array( $wp_query, 'lazyload_comment_meta' ), 10, 2 );
1377 $comments = &$wp_query->comments;
1378 $wp_query->comment_count = count($wp_query->comments);
1379 $wp_query->max_num_comment_pages = $comment_query->max_num_pages;
1381 if ( $separate_comments ) {
1382 $wp_query->comments_by_type = separate_comments($comments);
1383 $comments_by_type = &$wp_query->comments_by_type;
1385 $wp_query->comments_by_type = array();
1388 $overridden_cpage = false;
1389 if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) {
1390 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 );
1391 $overridden_cpage = true;
1394 if ( !defined('COMMENTS_TEMPLATE') )
1395 define('COMMENTS_TEMPLATE', true);
1397 $theme_template = STYLESHEETPATH . $file;
1399 * Filter the path to the theme template file used for the comments template.
1403 * @param string $theme_template The path to the theme template file.
1405 $include = apply_filters( 'comments_template', $theme_template );
1406 if ( file_exists( $include ) )
1407 require( $include );
1408 elseif ( file_exists( TEMPLATEPATH . $file ) )
1409 require( TEMPLATEPATH . $file );
1410 else // Backward compat code will be removed in a future release
1411 require( ABSPATH . WPINC . '/theme-compat/comments.php');
1415 * Display the JS popup script to show a comment.
1417 * If the $file parameter is empty, then the home page is assumed. The defaults
1418 * for the window are 400px by 400px.
1420 * For the comment link popup to work, this function has to be called or the
1421 * normal comment link will be assumed.
1423 * @global string $wpcommentspopupfile The URL to use for the popup window.
1424 * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
1428 * @param int $width Optional. The width of the popup window. Default 400.
1429 * @param int $height Optional. The height of the popup window. Default 400.
1430 * @param string $file Optional. Sets the location of the popup window.
1432 function comments_popup_script( $width = 400, $height = 400, $file = '' ) {
1433 global $wpcommentspopupfile, $wpcommentsjavascript;
1435 if (empty ($file)) {
1436 $wpcommentspopupfile = ''; // Use the index.
1438 $wpcommentspopupfile = $file;
1441 $wpcommentsjavascript = 1;
1442 $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
1447 * Displays the link to the comments popup window for the current post ID.
1449 * Is not meant to be displayed on single posts and pages. Should be used
1450 * on the lists of posts
1452 * @global string $wpcommentspopupfile The URL to use for the popup window.
1453 * @global int $wpcommentsjavascript Whether to use JavaScript. Set when function is called.
1457 * @param string $zero Optional. String to display when no comments. Default false.
1458 * @param string $one Optional. String to display when only one comment is available.
1460 * @param string $more Optional. String to display when there are more than one comment.
1462 * @param string $css_class Optional. CSS class to use for comments. Default empty.
1463 * @param string $none Optional. String to display when comments have been turned off.
1466 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) {
1467 global $wpcommentspopupfile, $wpcommentsjavascript;
1470 $title = get_the_title();
1471 $number = get_comments_number( $id );
1473 if ( false === $zero ) {
1474 /* translators: %s: post title */
1475 $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title );
1478 if ( false === $one ) {
1479 /* translators: %s: post title */
1480 $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title );
1483 if ( false === $more ) {
1484 /* translators: 1: Number of comments 2: post title */
1485 $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 );
1486 $more = sprintf( $more, number_format_i18n( $number ), $title );
1489 if ( false === $none ) {
1490 /* translators: %s: post title */
1491 $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title );
1494 if ( 0 == $number && !comments_open() && !pings_open() ) {
1495 echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>';
1499 if ( post_password_required() ) {
1500 _e( 'Enter your password to view comments.' );
1505 if ( $wpcommentsjavascript ) {
1506 if ( empty( $wpcommentspopupfile ) )
1509 $home = get_option('siteurl');
1510 echo $home . '/' . $wpcommentspopupfile . '?comments_popup=' . $id;
1511 echo '" onclick="wpopen(this.href); return false"';
1513 // if comments_popup_script() is not in the template, display simple comment link
1514 if ( 0 == $number ) {
1515 $respond_link = get_permalink() . '#respond';
1517 * Filter the respond link when a post has no comments.
1521 * @param string $respond_link The default response link.
1522 * @param integer $id The post ID.
1524 echo apply_filters( 'respond_link', $respond_link, $id );
1531 if ( !empty( $css_class ) ) {
1532 echo ' class="'.$css_class.'" ';
1537 * Filter the comments popup link attributes for display.
1541 * @param string $attributes The comments popup link attributes. Default empty.
1543 echo apply_filters( 'comments_popup_link_attributes', $attributes );
1546 comments_number( $zero, $one, $more );
1551 * Retrieve HTML content for reply to comment link.
1554 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object.
1556 * @param array $args {
1557 * Optional. Override default arguments.
1559 * @type string $add_below The first part of the selector used to identify the comment to respond below.
1560 * The resulting value is passed as the first parameter to addComment.moveForm(),
1561 * concatenated as $add_below-$comment->comment_ID. Default 'comment'.
1562 * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
1563 * to addComment.moveForm(), and appended to the link URL as a hash value.
1564 * Default 'respond'.
1565 * @type string $reply_text The text of the Reply link. Default 'Reply'.
1566 * @type string $login_text The text of the link to reply if logged out. Default 'Log in to Reply'.
1567 * @type int $depth' The depth of the new comment. Must be greater than 0 and less than the value
1568 * of the 'thread_comments_depth' option set in Settings > Discussion. Default 0.
1569 * @type string $before The text or HTML to add before the reply link. Default empty.
1570 * @type string $after The text or HTML to add after the reply link. Default empty.
1572 * @param int|WP_Comment $comment Comment being replied to. Default current comment.
1573 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
1574 * Default current post.
1575 * @return void|false|string Link to show comment form, if successful. False, if comments are closed.
1577 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) {
1579 'add_below' => 'comment',
1580 'respond_id' => 'respond',
1581 'reply_text' => __( 'Reply' ),
1582 'reply_to_text' => __( 'Reply to %s' ),
1583 'login_text' => __( 'Log in to Reply' ),
1589 $args = wp_parse_args( $args, $defaults );
1591 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) {
1595 $comment = get_comment( $comment );
1597 if ( empty( $post ) ) {
1598 $post = $comment->comment_post_ID;
1601 $post = get_post( $post );
1603 if ( ! comments_open( $post->ID ) ) {
1608 * Filter the comment reply link arguments.
1612 * @param array $args Comment reply link arguments. See get_comment_reply_link()
1613 * for more information on accepted arguments.
1614 * @param WP_Comment $comment The object of the comment being replied to.
1615 * @param WP_Post $post The WP_Post object.
1617 $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post );
1619 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) {
1620 $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
1621 esc_url( wp_login_url( get_permalink() ) ),
1625 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
1626 $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
1629 $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
1630 esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'],
1632 esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
1638 * Filter the comment reply link.
1642 * @param string $link The HTML markup for the comment reply link.
1643 * @param array $args An array of arguments overriding the defaults.
1644 * @param object $comment The object of the comment being replied.
1645 * @param WP_Post $post The WP_Post object.
1647 return apply_filters( 'comment_reply_link', $args['before'] . $link . $args['after'], $args, $comment, $post );
1651 * Displays the HTML content for reply to comment link.
1655 * @see get_comment_reply_link()
1657 * @param array $args Optional. Override default options.
1658 * @param int $comment Comment being replied to. Default current comment.
1659 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
1660 * Default current post.
1661 * @return mixed Link to show comment form, if successful. False, if comments are closed.
1663 function comment_reply_link($args = array(), $comment = null, $post = null) {
1664 echo get_comment_reply_link($args, $comment, $post);
1668 * Retrieve HTML content for reply to post link.
1672 * @param array $args {
1673 * Optional. Override default arguments.
1675 * @type string $add_below The first part of the selector used to identify the comment to respond below.
1676 * The resulting value is passed as the first parameter to addComment.moveForm(),
1677 * concatenated as $add_below-$comment->comment_ID. Default is 'post'.
1678 * @type string $respond_id The selector identifying the responding comment. Passed as the third parameter
1679 * to addComment.moveForm(), and appended to the link URL as a hash value.
1680 * Default 'respond'.
1681 * @type string $reply_text Text of the Reply link. Default is 'Leave a Comment'.
1682 * @type string $login_text Text of the link to reply if logged out. Default is 'Log in to leave a Comment'.
1683 * @type string $before Text or HTML to add before the reply link. Default empty.
1684 * @type string $after Text or HTML to add after the reply link. Default empty.
1686 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on.
1687 * Default current post.
1688 * @return false|null|string Link to show comment form, if successful. False, if comments are closed.
1690 function get_post_reply_link($args = array(), $post = null) {
1692 'add_below' => 'post',
1693 'respond_id' => 'respond',
1694 'reply_text' => __('Leave a Comment'),
1695 'login_text' => __('Log in to leave a Comment'),
1700 $args = wp_parse_args($args, $defaults);
1702 $post = get_post($post);
1704 if ( ! comments_open( $post->ID ) ) {
1708 if ( get_option('comment_registration') && ! is_user_logged_in() ) {
1709 $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>',
1710 wp_login_url( get_permalink() ),
1714 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )',
1715 $args['add_below'], $post->ID, $args['respond_id']
1718 $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>",
1719 get_permalink( $post->ID ) . '#' . $args['respond_id'],
1724 $formatted_link = $args['before'] . $link . $args['after'];
1727 * Filter the formatted post comments link HTML.
1731 * @param string $formatted The HTML-formatted post comments link.
1732 * @param int|WP_Post $post The post ID or WP_Post object.
1734 return apply_filters( 'post_comments_link', $formatted_link, $post );
1738 * Displays the HTML content for reply to post link.
1742 * @see get_post_reply_link()
1744 * @param array $args Optional. Override default options,
1745 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on.
1746 * Default current post.
1747 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed.
1749 function post_reply_link($args = array(), $post = null) {
1750 echo get_post_reply_link($args, $post);
1754 * Retrieve HTML content for cancel comment reply link.
1758 * @param string $text Optional. Text to display for cancel reply link. Default empty.
1761 function get_cancel_comment_reply_link( $text = '' ) {
1763 $text = __('Click here to cancel reply.');
1765 $style = isset($_GET['replytocom']) ? '' : ' style="display:none;"';
1766 $link = esc_html( remove_query_arg('replytocom') ) . '#respond';
1768 $formatted_link = '<a rel="nofollow" id="cancel-comment-reply-link" href="' . $link . '"' . $style . '>' . $text . '</a>';
1771 * Filter the cancel comment reply link HTML.
1775 * @param string $formatted_link The HTML-formatted cancel comment reply link.
1776 * @param string $link Cancel comment reply link URL.
1777 * @param string $text Cancel comment reply link text.
1779 return apply_filters( 'cancel_comment_reply_link', $formatted_link, $link, $text );
1783 * Display HTML content for cancel comment reply link.
1787 * @param string $text Optional. Text to display for cancel reply link. Default empty.
1789 function cancel_comment_reply_link( $text = '' ) {
1790 echo get_cancel_comment_reply_link($text);
1794 * Retrieve hidden input HTML for replying to comments.
1798 * @param int $id Optional. Post ID. Default current post ID.
1799 * @return string Hidden input HTML for replying to comments
1801 function get_comment_id_fields( $id = 0 ) {
1805 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
1806 $result = "<input type='hidden' name='comment_post_ID' value='$id' id='comment_post_ID' />\n";
1807 $result .= "<input type='hidden' name='comment_parent' id='comment_parent' value='$replytoid' />\n";
1810 * Filter the returned comment id fields.
1814 * @param string $result The HTML-formatted hidden id field comment elements.
1815 * @param int $id The post ID.
1816 * @param int $replytoid The id of the comment being replied to.
1818 return apply_filters( 'comment_id_fields', $result, $id, $replytoid );
1822 * Output hidden input HTML for replying to comments.
1826 * @param int $id Optional. Post ID. Default current post ID.
1828 function comment_id_fields( $id = 0 ) {
1829 echo get_comment_id_fields( $id );
1833 * Display text based on comment reply status.
1835 * Only affects users with JavaScript disabled.
1839 * @param string $noreplytext Optional. Text to display when not replying to a comment.
1841 * @param string $replytext Optional. Text to display when replying to a comment.
1842 * Default false. Accepts "%s" for the author of the comment
1844 * @param string $linktoparent Optional. Boolean to control making the author's name a link
1845 * to their comment. Default true.
1847 function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) {
1848 $comment = get_comment();
1850 if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' );
1851 if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' );
1853 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0;
1855 if ( 0 == $replytoid )
1858 $comment = get_comment($replytoid);
1859 $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment );
1860 printf( $replytext, $author );
1867 * Used in the comments.php template to list comments for a particular post.
1871 * @see WP_Query->comments
1873 * @global WP_Query $wp_query
1874 * @global int $comment_alt
1875 * @global int $comment_depth
1876 * @global int $comment_thread_alt
1877 * @global bool $overridden_cpage
1878 * @global bool $in_comment_loop
1880 * @param string|array $args {
1881 * Optional. Formatting options.
1883 * @type object $walker Instance of a Walker class to list comments. Default null.
1884 * @type int $max_depth The maximum comments depth. Default empty.
1885 * @type string $style The style of list ordering. Default 'ul'. Accepts 'ul', 'ol'.
1886 * @type string $callback Callback function to use. Default null.
1887 * @type string $end-callback Callback function to use at the end. Default null.
1888 * @type string $type Type of comments to list.
1889 * Default 'all'. Accepts 'all', 'comment', 'pingback', 'trackback', 'pings'.
1890 * @type int $page Page ID to list comments for. Default empty.
1891 * @type int $per_page Number of comments to list per page. Default empty.
1892 * @type int $avatar_size Height and width dimensions of the avatar size. Default 32.
1893 * @type string $reverse_top_level Ordering of the listed comments. Default null. Accepts 'desc', 'asc'.
1894 * @type bool $reverse_children Whether to reverse child comments in the list. Default null.
1895 * @type string $format How to format the comments list.
1896 * Default 'html5' if the theme supports it. Accepts 'html5', 'xhtml'.
1897 * @type bool $short_ping Whether to output short pings. Default false.
1898 * @type bool $echo Whether to echo the output or return it. Default true.
1900 * @param array $comments Optional. Array of WP_Comment objects.
1902 function wp_list_comments( $args = array(), $comments = null ) {
1903 global $wp_query, $comment_alt, $comment_depth, $comment_thread_alt, $overridden_cpage, $in_comment_loop;
1905 $in_comment_loop = true;
1907 $comment_alt = $comment_thread_alt = 0;
1915 'end-callback' => null,
1919 'avatar_size' => 32,
1920 'reverse_top_level' => null,
1921 'reverse_children' => '',
1922 'format' => current_theme_supports( 'html5', 'comment-list' ) ? 'html5' : 'xhtml',
1923 'short_ping' => false,
1927 $r = wp_parse_args( $args, $defaults );
1930 * Filter the arguments used in retrieving the comment list.
1934 * @see wp_list_comments()
1936 * @param array $r An array of arguments for displaying comments.
1938 $r = apply_filters( 'wp_list_comments_args', $r );
1940 // Figure out what comments we'll be looping through ($_comments)
1941 if ( null !== $comments ) {
1942 $comments = (array) $comments;
1943 if ( empty($comments) )
1945 if ( 'all' != $r['type'] ) {
1946 $comments_by_type = separate_comments($comments);
1947 if ( empty($comments_by_type[$r['type']]) )
1949 $_comments = $comments_by_type[$r['type']];
1951 $_comments = $comments;
1955 * If 'page' or 'per_page' has been passed, and does not match what's in $wp_query,
1956 * perform a separate comment query and allow Walker_Comment to paginate.
1958 if ( $r['page'] || $r['per_page'] ) {
1959 $current_cpage = get_query_var( 'cpage' );
1960 if ( ! $current_cpage ) {
1961 $current_cpage = 'newest' === get_option( 'default_comments_page' ) ? 1 : $wp_query->max_num_comment_pages;
1964 $current_per_page = get_query_var( 'comments_per_page' );
1965 if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) {
1967 $comments = get_comments( array(
1968 'post_id' => get_the_ID(),
1969 'orderby' => 'comment_date_gmt',
1974 if ( 'all' != $r['type'] ) {
1975 $comments_by_type = separate_comments( $comments );
1976 if ( empty( $comments_by_type[ $r['type'] ] ) ) {
1980 $_comments = $comments_by_type[ $r['type'] ];
1982 $_comments = $comments;
1986 // Otherwise, fall back on the comments from `$wp_query->comments`.
1988 if ( empty($wp_query->comments) )
1990 if ( 'all' != $r['type'] ) {
1991 if ( empty($wp_query->comments_by_type) )
1992 $wp_query->comments_by_type = separate_comments($wp_query->comments);
1993 if ( empty($wp_query->comments_by_type[$r['type']]) )
1995 $_comments = $wp_query->comments_by_type[$r['type']];
1997 $_comments = $wp_query->comments;
2000 if ( $wp_query->max_num_comment_pages ) {
2001 $default_comments_page = get_option( 'default_comments_page' );
2002 $cpage = get_query_var( 'cpage' );
2003 if ( 'newest' === $default_comments_page ) {
2004 $r['cpage'] = $cpage;
2007 * When first page shows oldest comments, post permalink is the same as
2008 * the comment permalink.
2010 } elseif ( $cpage == 1 ) {
2013 $r['cpage'] = $cpage;
2022 if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) {
2023 $r['per_page'] = get_query_var('comments_per_page');
2026 if ( empty($r['per_page']) ) {
2031 if ( '' === $r['max_depth'] ) {
2032 if ( get_option('thread_comments') )
2033 $r['max_depth'] = get_option('thread_comments_depth');
2035 $r['max_depth'] = -1;
2038 if ( '' === $r['page'] ) {
2039 if ( empty($overridden_cpage) ) {
2040 $r['page'] = get_query_var('cpage');
2042 $threaded = ( -1 != $r['max_depth'] );
2043 $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1;
2044 set_query_var( 'cpage', $r['page'] );
2048 $r['page'] = intval($r['page']);
2049 if ( 0 == $r['page'] && 0 != $r['per_page'] )
2052 if ( null === $r['reverse_top_level'] )
2053 $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') );
2055 if ( empty( $r['walker'] ) ) {
2056 $walker = new Walker_Comment;
2058 $walker = $r['walker'];
2061 $output = $walker->paged_walk( $_comments, $r['max_depth'], $r['page'], $r['per_page'], $r );
2063 $in_comment_loop = false;
2073 * Output a complete commenting form for use within a template.
2075 * Most strings and form fields may be controlled through the $args array passed
2076 * into the function, while you may also choose to use the comment_form_default_fields
2077 * filter to modify the array of default fields if you'd just like to add a new
2078 * one or remove a single field. All fields are also individually passed through
2079 * a filter of the form comment_form_field_$name where $name is the key used
2080 * in the array of fields.
2083 * @since 4.1.0 Introduced the 'class_submit' argument.
2084 * @since 4.2.0 Introduced the 'submit_button' and 'submit_fields' arguments.
2085 * @since 4.4.0 Introduced the 'class_form', 'title_reply_before', 'title_reply_after',
2086 * 'cancel_reply_before', and 'cancel_reply_after' arguments.
2088 * @param array $args {
2089 * Optional. Default arguments and form fields to override.
2091 * @type array $fields {
2092 * Default comment fields, filterable by default via the 'comment_form_default_fields' hook.
2094 * @type string $author Comment author field HTML.
2095 * @type string $email Comment author email field HTML.
2096 * @type string $url Comment author URL field HTML.
2098 * @type string $comment_field The comment textarea field HTML.
2099 * @type string $must_log_in HTML element for a 'must be logged in to comment' message.
2100 * @type string $logged_in_as HTML element for a 'logged in as [user]' message.
2101 * @type string $comment_notes_before HTML element for a message displayed before the comment fields
2102 * if the user is not logged in.
2103 * Default 'Your email address will not be published.'.
2104 * @type string $comment_notes_after HTML element for a message displayed after the textarea field.
2105 * @type string $id_form The comment form element id attribute. Default 'commentform'.
2106 * @type string $id_submit The comment submit element id attribute. Default 'submit'.
2107 * @type string $class_form The comment form element class attribute. Default 'comment-form'.
2108 * @type string $class_submit The comment submit element class attribute. Default 'submit'.
2109 * @type string $name_submit The comment submit element name attribute. Default 'submit'.
2110 * @type string $title_reply The translatable 'reply' button label. Default 'Leave a Reply'.
2111 * @type string $title_reply_to The translatable 'reply-to' button label. Default 'Leave a Reply to %s',
2112 * where %s is the author of the comment being replied to.
2113 * @type string $title_reply_before HTML displayed before the comment form title.
2114 * Default: '<h3 id="reply-title" class="comment-reply-title">'.
2115 * @type string $title_reply_after HTML displayed after the comment form title.
2117 * @type string $cancel_reply_before HTML displayed before the cancel reply link.
2118 * @type string $cancel_reply_after HTML displayed after the cancel reply link.
2119 * @type string $cancel_reply_link The translatable 'cancel reply' button label. Default 'Cancel reply'.
2120 * @type string $label_submit The translatable 'submit' button label. Default 'Post a comment'.
2121 * @type string $submit_button HTML format for the Submit button.
2122 * Default: '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'.
2123 * @type string $submit_field HTML format for the markup surrounding the Submit button and comment hidden
2124 * fields. Default: '<p class="form-submit">%1$s %2$s</a>', where %1$s is the
2125 * submit button markup and %2$s is the comment hidden fields.
2126 * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'.
2128 * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post.
2130 function comment_form( $args = array(), $post_id = null ) {
2131 if ( null === $post_id )
2132 $post_id = get_the_ID();
2134 $commenter = wp_get_current_commenter();
2135 $user = wp_get_current_user();
2136 $user_identity = $user->exists() ? $user->display_name : '';
2138 $args = wp_parse_args( $args );
2139 if ( ! isset( $args['format'] ) )
2140 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
2142 $req = get_option( 'require_name_email' );
2143 $aria_req = ( $req ? " aria-required='true'" : '' );
2144 $html_req = ( $req ? " required='required'" : '' );
2145 $html5 = 'html5' === $args['format'];
2147 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
2148 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . $html_req . ' /></p>',
2149 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' .
2150 '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-describedby="email-notes"' . $aria_req . $html_req . ' /></p>',
2151 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' .
2152 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',
2155 $required_text = sprintf( ' ' . __('Required fields are marked %s'), '<span class="required">*</span>' );
2158 * Filter the default comment form fields.
2162 * @param array $fields The default comment fields.
2164 $fields = apply_filters( 'comment_form_default_fields', $fields );
2166 'fields' => $fields,
2167 '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" required="required"></textarea></p>',
2168 /** This filter is documented in wp-includes/link-template.php */
2169 '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>',
2170 /** This filter is documented in wp-includes/link-template.php */
2171 'logged_in_as' => '<p class="logged-in-as">' . sprintf( __( '<a href="%1$s" aria-label="Logged in as %2$s. Edit your profile.">Logged in as %2$s</a>. <a href="%3$s">Log out?</a>' ), get_edit_user_link(), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>',
2172 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>',
2173 'comment_notes_after' => '',
2174 'id_form' => 'commentform',
2175 'id_submit' => 'submit',
2176 'class_form' => 'comment-form',
2177 'class_submit' => 'submit',
2178 'name_submit' => 'submit',
2179 'title_reply' => __( 'Leave a Reply' ),
2180 'title_reply_to' => __( 'Leave a Reply to %s' ),
2181 'title_reply_before' => '<h3 id="reply-title" class="comment-reply-title">',
2182 'title_reply_after' => '</h3>',
2183 'cancel_reply_before' => ' <small>',
2184 'cancel_reply_after' => '</small>',
2185 'cancel_reply_link' => __( 'Cancel reply' ),
2186 'label_submit' => __( 'Post Comment' ),
2187 'submit_button' => '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />',
2188 'submit_field' => '<p class="form-submit">%1$s %2$s</p>',
2189 'format' => 'xhtml',
2193 * Filter the comment form default arguments.
2195 * Use 'comment_form_default_fields' to filter the comment fields.
2199 * @param array $defaults The default comment form arguments.
2201 $args = wp_parse_args( $args, apply_filters( 'comment_form_defaults', $defaults ) );
2203 // Ensure that the filtered args contain all required default values.
2204 $args = array_merge( $defaults, $args );
2206 if ( comments_open( $post_id ) ) : ?>
2209 * Fires before the comment form.
2213 do_action( 'comment_form_before' );
2215 <div id="respond" class="comment-respond">
2217 echo $args['title_reply_before'];
2219 comment_form_title( $args['title_reply'], $args['title_reply_to'] );
2221 echo $args['cancel_reply_before'];
2223 cancel_comment_reply_link( $args['cancel_reply_link'] );
2225 echo $args['cancel_reply_after'];
2227 echo $args['title_reply_after'];
2229 if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) :
2230 echo $args['must_log_in'];
2232 * Fires after the HTML-formatted 'must log in after' message in the comment form.
2236 do_action( 'comment_form_must_log_in_after' );
2238 <form action="<?php echo site_url( '/wp-comments-post.php' ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>>
2241 * Fires at the top of the comment form, inside the form tag.
2245 do_action( 'comment_form_top' );
2247 if ( is_user_logged_in() ) :
2249 * Filter the 'logged in' message for the comment form for display.
2253 * @param string $args_logged_in The logged-in-as HTML-formatted message.
2254 * @param array $commenter An array containing the comment author's
2255 * username, email, and URL.
2256 * @param string $user_identity If the commenter is a registered user,
2257 * the display name, blank otherwise.
2259 echo apply_filters( 'comment_form_logged_in', $args['logged_in_as'], $commenter, $user_identity );
2262 * Fires after the is_user_logged_in() check in the comment form.
2266 * @param array $commenter An array containing the comment author's
2267 * username, email, and URL.
2268 * @param string $user_identity If the commenter is a registered user,
2269 * the display name, blank otherwise.
2271 do_action( 'comment_form_logged_in_after', $commenter, $user_identity );
2275 echo $args['comment_notes_before'];
2279 // Prepare an array of all fields, including the textarea
2280 $comment_fields = array( 'comment' => $args['comment_field'] ) + (array) $args['fields'];
2283 * Filter the comment form fields.
2287 * @param array $comment_fields The comment fields.
2289 $comment_fields = apply_filters( 'comment_form_fields', $comment_fields );
2291 // Get an array of field names, excluding the textarea
2292 $comment_field_keys = array_diff( array_keys( $comment_fields ), array( 'comment' ) );
2294 // Get the first and the last field name, excluding the textarea
2295 $first_field = reset( $comment_field_keys );
2296 $last_field = end( $comment_field_keys );
2298 foreach ( $comment_fields as $name => $field ) {
2300 if ( 'comment' === $name ) {
2303 * Filter the content of the comment textarea field for display.
2307 * @param string $args_comment_field The content of the comment textarea field.
2309 echo apply_filters( 'comment_form_field_comment', $field );
2311 echo $args['comment_notes_after'];
2313 } elseif ( ! is_user_logged_in() ) {
2315 if ( $first_field === $name ) {
2317 * Fires before the comment fields in the comment form, excluding the textarea.
2321 do_action( 'comment_form_before_fields' );
2325 * Filter a comment form field for display.
2327 * The dynamic portion of the filter hook, `$name`, refers to the name
2328 * of the comment form field. Such as 'author', 'email', or 'url'.
2332 * @param string $field The HTML-formatted output of the comment form field.
2334 echo apply_filters( "comment_form_field_{$name}", $field ) . "\n";
2336 if ( $last_field === $name ) {
2338 * Fires after the comment fields in the comment form, excluding the textarea.
2342 do_action( 'comment_form_after_fields' );
2347 $submit_button = sprintf(
2348 $args['submit_button'],
2349 esc_attr( $args['name_submit'] ),
2350 esc_attr( $args['id_submit'] ),
2351 esc_attr( $args['class_submit'] ),
2352 esc_attr( $args['label_submit'] )
2356 * Filter the submit button for the comment form to display.
2360 * @param string $submit_button HTML markup for the submit button.
2361 * @param array $args Arguments passed to `comment_form()`.
2363 $submit_button = apply_filters( 'comment_form_submit_button', $submit_button, $args );
2365 $submit_field = sprintf(
2366 $args['submit_field'],
2368 get_comment_id_fields( $post_id )
2372 * Filter the submit field for the comment form to display.
2374 * The submit field includes the submit button, hidden fields for the
2375 * comment form, and any wrapper markup.
2379 * @param string $submit_field HTML markup for the submit field.
2380 * @param array $args Arguments passed to comment_form().
2382 echo apply_filters( 'comment_form_submit_field', $submit_field, $args );
2385 * Fires at the bottom of the comment form, inside the closing </form> tag.
2389 * @param int $post_id The post ID.
2391 do_action( 'comment_form', $post_id );
2395 </div><!-- #respond -->
2398 * Fires after the comment form.
2402 do_action( 'comment_form_after' );
2405 * Fires after the comment form if comments are closed.
2409 do_action( 'comment_form_comments_closed' );