16 * |
16 * |
17 * @since 1.5.0 |
17 * @since 1.5.0 |
18 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
18 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
19 * |
19 * |
20 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to retrieve the author. |
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. |
21 * Default current comment. |
22 * @return string The comment author |
22 * @return string The comment author |
23 */ |
23 */ |
24 function get_comment_author( $comment_ID = 0 ) { |
24 function get_comment_author( $comment_ID = 0 ) { |
25 $comment = get_comment( $comment_ID ); |
25 $comment = get_comment( $comment_ID ); |
26 |
26 |
27 if ( empty( $comment->comment_author ) ) { |
27 if ( empty( $comment->comment_author ) ) { |
28 if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) |
28 if ( $comment->user_id && $user = get_userdata( $comment->user_id ) ) { |
29 $author = $user->display_name; |
29 $author = $user->display_name; |
30 else |
30 } else { |
31 $author = __('Anonymous'); |
31 $author = __( 'Anonymous' ); |
|
32 } |
32 } else { |
33 } else { |
33 $author = $comment->comment_author; |
34 $author = $comment->comment_author; |
34 } |
35 } |
35 |
36 |
36 /** |
37 /** |
99 |
100 |
100 /** |
101 /** |
101 * Display the email of the author of the current global $comment. |
102 * Display the email of the author of the current global $comment. |
102 * |
103 * |
103 * Care should be taken to protect the email address and assure that email |
104 * 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 * harvesters do not capture your commenter's email address. Most assume that |
105 * their email address will not appear in raw form on the site. Doing so will |
106 * their email address will not appear in raw form on the site. Doing so will |
106 * enable anyone, including those that people don't want to get the email |
107 * 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. |
108 * address and use it for their own means good and bad. |
108 * |
109 * |
109 * @since 0.71 |
110 * @since 0.71 |
110 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
111 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
111 * |
112 * |
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 * @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. |
114 * Default current comment. |
114 */ |
115 */ |
115 function comment_author_email( $comment_ID = 0 ) { |
116 function comment_author_email( $comment_ID = 0 ) { |
116 $comment = get_comment( $comment_ID ); |
117 $comment = get_comment( $comment_ID ); |
117 $author_email = get_comment_author_email( $comment ); |
118 $author_email = get_comment_author_email( $comment ); |
118 |
119 |
208 * |
209 * |
209 * @since 1.5.0 |
210 * @since 1.5.0 |
210 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
211 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
211 * |
212 * |
212 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
213 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's link. |
213 * Default current comment. |
214 * Default current comment. |
214 * @return string The comment author name or HTML link for author's URL. |
215 * @return string The comment author name or HTML link for author's URL. |
215 */ |
216 */ |
216 function get_comment_author_link( $comment_ID = 0 ) { |
217 function get_comment_author_link( $comment_ID = 0 ) { |
217 $comment = get_comment( $comment_ID ); |
218 $comment = get_comment( $comment_ID ); |
218 $url = get_comment_author_url( $comment ); |
219 $url = get_comment_author_url( $comment ); |
219 $author = get_comment_author( $comment ); |
220 $author = get_comment_author( $comment ); |
220 |
221 |
221 if ( empty( $url ) || 'http://' == $url ) |
222 if ( empty( $url ) || 'http://' == $url ) { |
222 $return = $author; |
223 $return = $author; |
223 else |
224 } else { |
224 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
225 $return = "<a href='$url' rel='external nofollow' class='url'>$author</a>"; |
|
226 } |
225 |
227 |
226 /** |
228 /** |
227 * Filters the comment author's link for display. |
229 * Filters the comment author's link for display. |
228 * |
230 * |
229 * @since 1.5.0 |
231 * @since 1.5.0 |
294 * |
296 * |
295 * @since 1.5.0 |
297 * @since 1.5.0 |
296 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
298 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
297 * |
299 * |
298 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
300 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's URL. |
299 * Default current comment. |
301 * Default current comment. |
300 * @return string Comment author URL. |
302 * @return string Comment author URL. |
301 */ |
303 */ |
302 function get_comment_author_url( $comment_ID = 0 ) { |
304 function get_comment_author_url( $comment_ID = 0 ) { |
303 $comment = get_comment( $comment_ID ); |
305 $comment = get_comment( $comment_ID ); |
304 $url = ''; |
306 $url = ''; |
305 $id = 0; |
307 $id = 0; |
306 if ( ! empty( $comment ) ) { |
308 if ( ! empty( $comment ) ) { |
307 $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; |
309 $author_url = ( 'http://' == $comment->comment_author_url ) ? '' : $comment->comment_author_url; |
308 $url = esc_url( $author_url, array( 'http', 'https' ) ); |
310 $url = esc_url( $author_url, array( 'http', 'https' ) ); |
309 $id = $comment->comment_ID; |
311 $id = $comment->comment_ID; |
310 } |
312 } |
311 |
313 |
312 /** |
314 /** |
313 * Filters the comment author's URL. |
315 * Filters the comment author's URL. |
314 * |
316 * |
369 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
371 * @param int|WP_Comment $comment Optional. Comment ID or WP_Comment object. |
370 * Default is the current comment. |
372 * Default is the current comment. |
371 * @return string The HTML link between the $before and $after parameters. |
373 * @return string The HTML link between the $before and $after parameters. |
372 */ |
374 */ |
373 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
375 function get_comment_author_url_link( $linktext = '', $before = '', $after = '', $comment = 0 ) { |
374 $url = get_comment_author_url( $comment ); |
376 $url = get_comment_author_url( $comment ); |
375 $display = ($linktext != '') ? $linktext : $url; |
377 $display = ( $linktext != '' ) ? $linktext : $url; |
376 $display = str_replace( 'http://www.', '', $display ); |
378 $display = str_replace( 'http://www.', '', $display ); |
377 $display = str_replace( 'http://', '', $display ); |
379 $display = str_replace( 'http://', '', $display ); |
378 |
380 |
379 if ( '/' == substr($display, -1) ) { |
381 if ( '/' == substr( $display, -1 ) ) { |
380 $display = substr($display, 0, -1); |
382 $display = substr( $display, 0, -1 ); |
381 } |
383 } |
382 |
384 |
383 $return = "$before<a href='$url' rel='external'>$display</a>$after"; |
385 $return = "$before<a href='$url' rel='external'>$display</a>$after"; |
384 |
386 |
385 /** |
387 /** |
426 * @return string If `$echo` is false, the class will be returned. Void otherwise. |
428 * @return string If `$echo` is false, the class will be returned. Void otherwise. |
427 */ |
429 */ |
428 function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
430 function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
429 // Separates classes with a single space, collates classes for comment DIV |
431 // Separates classes with a single space, collates classes for comment DIV |
430 $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
432 $class = 'class="' . join( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
431 if ( $echo) |
433 if ( $echo ) { |
432 echo $class; |
434 echo $class; |
433 else |
435 } else { |
434 return $class; |
436 return $class; |
|
437 } |
435 } |
438 } |
436 |
439 |
437 /** |
440 /** |
438 * Returns the classes for the comment div as an array. |
441 * Returns the classes for the comment div as an array. |
439 * |
442 * |
465 // Add classes for comment authors that are registered users. |
468 // Add classes for comment authors that are registered users. |
466 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
469 if ( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) ) { |
467 $classes[] = 'byuser'; |
470 $classes[] = 'byuser'; |
468 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
471 $classes[] = 'comment-author-' . sanitize_html_class( $user->user_nicename, $comment->user_id ); |
469 // For comment authors who are the author of the post |
472 // For comment authors who are the author of the post |
470 if ( $post = get_post($post_id) ) { |
473 if ( $post = get_post( $post_id ) ) { |
471 if ( $comment->user_id === $post->post_author ) { |
474 if ( $comment->user_id === $post->post_author ) { |
472 $classes[] = 'bypostauthor'; |
475 $classes[] = 'bypostauthor'; |
473 } |
476 } |
474 } |
477 } |
475 } |
478 } |
476 |
479 |
477 if ( empty($comment_alt) ) |
480 if ( empty( $comment_alt ) ) { |
478 $comment_alt = 0; |
481 $comment_alt = 0; |
479 if ( empty($comment_depth) ) |
482 } |
|
483 if ( empty( $comment_depth ) ) { |
480 $comment_depth = 1; |
484 $comment_depth = 1; |
481 if ( empty($comment_thread_alt) ) |
485 } |
|
486 if ( empty( $comment_thread_alt ) ) { |
482 $comment_thread_alt = 0; |
487 $comment_thread_alt = 0; |
|
488 } |
483 |
489 |
484 if ( $comment_alt % 2 ) { |
490 if ( $comment_alt % 2 ) { |
485 $classes[] = 'odd'; |
491 $classes[] = 'odd'; |
486 $classes[] = 'alt'; |
492 $classes[] = 'alt'; |
487 } else { |
493 } else { |
501 $comment_thread_alt++; |
507 $comment_thread_alt++; |
502 } |
508 } |
503 |
509 |
504 $classes[] = "depth-$comment_depth"; |
510 $classes[] = "depth-$comment_depth"; |
505 |
511 |
506 if ( !empty($class) ) { |
512 if ( ! empty( $class ) ) { |
507 if ( !is_array( $class ) ) |
513 if ( ! is_array( $class ) ) { |
508 $class = preg_split('#\s+#', $class); |
514 $class = preg_split( '#\s+#', $class ); |
509 $classes = array_merge($classes, $class); |
515 } |
510 } |
516 $classes = array_merge( $classes, $class ); |
511 |
517 } |
512 $classes = array_map('esc_attr', $classes); |
518 |
|
519 $classes = array_map( 'esc_attr', $classes ); |
513 |
520 |
514 /** |
521 /** |
515 * Filters the returned CSS classes for the current comment. |
522 * Filters the returned CSS classes for the current comment. |
516 * |
523 * |
517 * @since 2.7.0 |
524 * @since 2.7.0 |
518 * |
525 * |
519 * @param array $classes An array of comment classes. |
526 * @param string[] $classes An array of comment classes. |
520 * @param string $class A comma-separated list of additional classes added to the list. |
527 * @param string $class A comma-separated list of additional classes added to the list. |
521 * @param int $comment_id The comment id. |
528 * @param int $comment_id The comment id. |
522 * @param WP_Comment $comment The comment object. |
529 * @param WP_Comment $comment The comment object. |
523 * @param int|WP_Post $post_id The post ID or WP_Post object. |
530 * @param int|WP_Post $post_id The post ID or WP_Post object. |
524 */ |
531 */ |
581 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
589 * @param int|WP_Comment $comment_ID WP_Comment or ID of the comment for which to get the excerpt. |
582 * Default current comment. |
590 * Default current comment. |
583 * @return string The maybe truncated comment with 20 words or less. |
591 * @return string The maybe truncated comment with 20 words or less. |
584 */ |
592 */ |
585 function get_comment_excerpt( $comment_ID = 0 ) { |
593 function get_comment_excerpt( $comment_ID = 0 ) { |
586 $comment = get_comment( $comment_ID ); |
594 $comment = get_comment( $comment_ID ); |
587 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); |
595 $comment_text = strip_tags( str_replace( array( "\n", "\r" ), ' ', $comment->comment_content ) ); |
588 $words = explode( ' ', $comment_text ); |
596 $words = explode( ' ', $comment_text ); |
589 |
597 |
590 /** |
598 /** |
591 * Filters the amount of words used in the comment excerpt. |
599 * Filters the amount of words used in the comment excerpt. |
592 * |
600 * |
593 * @since 4.4.0 |
601 * @since 4.4.0 |
714 'page' => '', |
722 'page' => '', |
715 'per_page' => '', |
723 'per_page' => '', |
716 'max_depth' => '', |
724 'max_depth' => '', |
717 'cpage' => null, |
725 'cpage' => null, |
718 ); |
726 ); |
719 $args = wp_parse_args( $args, $defaults ); |
727 $args = wp_parse_args( $args, $defaults ); |
720 |
728 |
721 $link = get_permalink( $comment->comment_post_ID ); |
729 $link = get_permalink( $comment->comment_post_ID ); |
722 |
730 |
723 // The 'cpage' param takes precedence. |
731 // The 'cpage' param takes precedence. |
724 if ( ! is_null( $args['cpage'] ) ) { |
732 if ( ! is_null( $args['cpage'] ) ) { |
725 $cpage = $args['cpage']; |
733 $cpage = $args['cpage']; |
726 |
734 |
727 // No 'cpage' is provided, so we calculate one. |
735 // No 'cpage' is provided, so we calculate one. |
728 } else { |
736 } else { |
729 if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { |
737 if ( '' === $args['per_page'] && get_option( 'page_comments' ) ) { |
730 $args['per_page'] = get_option('comments_per_page'); |
738 $args['per_page'] = get_option( 'comments_per_page' ); |
731 } |
739 } |
732 |
740 |
733 if ( empty( $args['per_page'] ) ) { |
741 if ( empty( $args['per_page'] ) ) { |
734 $args['per_page'] = 0; |
742 $args['per_page'] = 0; |
735 $args['page'] = 0; |
743 $args['page'] = 0; |
736 } |
744 } |
737 |
745 |
738 $cpage = $args['page']; |
746 $cpage = $args['page']; |
739 |
747 |
740 if ( '' == $cpage ) { |
748 if ( '' == $cpage ) { |
820 * |
827 * |
821 * @param string $deprecated Not Used. |
828 * @param string $deprecated Not Used. |
822 * @param string $deprecated_2 Not Used. |
829 * @param string $deprecated_2 Not Used. |
823 */ |
830 */ |
824 function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
831 function comments_link( $deprecated = '', $deprecated_2 = '' ) { |
825 if ( !empty( $deprecated ) ) |
832 if ( ! empty( $deprecated ) ) { |
826 _deprecated_argument( __FUNCTION__, '0.72' ); |
833 _deprecated_argument( __FUNCTION__, '0.72' ); |
827 if ( !empty( $deprecated_2 ) ) |
834 } |
|
835 if ( ! empty( $deprecated_2 ) ) { |
828 _deprecated_argument( __FUNCTION__, '1.3.0' ); |
836 _deprecated_argument( __FUNCTION__, '1.3.0' ); |
|
837 } |
829 echo esc_url( get_comments_link() ); |
838 echo esc_url( get_comments_link() ); |
830 } |
839 } |
831 |
840 |
832 /** |
841 /** |
833 * Retrieves the amount of comments a post has. |
842 * Retrieves the amount of comments a post has. |
1051 * Default current comment. |
1061 * Default current comment. |
1052 * @return string The comment type. |
1062 * @return string The comment type. |
1053 */ |
1063 */ |
1054 function get_comment_type( $comment_ID = 0 ) { |
1064 function get_comment_type( $comment_ID = 0 ) { |
1055 $comment = get_comment( $comment_ID ); |
1065 $comment = get_comment( $comment_ID ); |
1056 if ( '' == $comment->comment_type ) |
1066 if ( '' == $comment->comment_type ) { |
1057 $comment->comment_type = 'comment'; |
1067 $comment->comment_type = 'comment'; |
|
1068 } |
1058 |
1069 |
1059 /** |
1070 /** |
1060 * Filters the returned comment type. |
1071 * Filters the returned comment type. |
1061 * |
1072 * |
1062 * @since 1.5.0 |
1073 * @since 1.5.0 |
1063 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
1074 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
1064 * |
1075 * |
1065 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. |
1076 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. |
1066 * @param int $comment_ID The comment ID. |
1077 * @param int $comment_ID The comment ID. |
1067 * @param WP_Comment $comment The comment object. |
1078 * @param WP_Comment $comment The comment object. |
1068 */ |
1079 */ |
1069 return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
1080 return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
1070 } |
1081 } |
1071 |
1082 |
1077 * @param string $commenttxt Optional. String to display for comment type. Default false. |
1088 * @param string $commenttxt Optional. String to display for comment type. Default false. |
1078 * @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
1089 * @param string $trackbacktxt Optional. String to display for trackback type. Default false. |
1079 * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
1090 * @param string $pingbacktxt Optional. String to display for pingback type. Default false. |
1080 */ |
1091 */ |
1081 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
1092 function comment_type( $commenttxt = false, $trackbacktxt = false, $pingbacktxt = false ) { |
1082 if ( false === $commenttxt ) $commenttxt = _x( 'Comment', 'noun' ); |
1093 if ( false === $commenttxt ) { |
1083 if ( false === $trackbacktxt ) $trackbacktxt = __( 'Trackback' ); |
1094 $commenttxt = _x( 'Comment', 'noun' ); |
1084 if ( false === $pingbacktxt ) $pingbacktxt = __( 'Pingback' ); |
1095 } |
|
1096 if ( false === $trackbacktxt ) { |
|
1097 $trackbacktxt = __( 'Trackback' ); |
|
1098 } |
|
1099 if ( false === $pingbacktxt ) { |
|
1100 $pingbacktxt = __( 'Pingback' ); |
|
1101 } |
1085 $type = get_comment_type(); |
1102 $type = get_comment_type(); |
1086 switch( $type ) { |
1103 switch ( $type ) { |
1087 case 'trackback' : |
1104 case 'trackback': |
1088 echo $trackbacktxt; |
1105 echo $trackbacktxt; |
1089 break; |
1106 break; |
1090 case 'pingback' : |
1107 case 'pingback': |
1091 echo $pingbacktxt; |
1108 echo $pingbacktxt; |
1092 break; |
1109 break; |
1093 default : |
1110 default: |
1094 echo $commenttxt; |
1111 echo $commenttxt; |
1095 } |
1112 } |
1096 } |
1113 } |
1097 |
1114 |
1098 /** |
1115 /** |
1131 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
1149 * @return void|string Should only be used to echo the trackback URL, use get_trackback_url() |
1132 * for the result instead. |
1150 * for the result instead. |
1133 */ |
1151 */ |
1134 function trackback_url( $deprecated_echo = true ) { |
1152 function trackback_url( $deprecated_echo = true ) { |
1135 if ( true !== $deprecated_echo ) { |
1153 if ( true !== $deprecated_echo ) { |
1136 _deprecated_argument( __FUNCTION__, '2.5.0', |
1154 _deprecated_argument( |
|
1155 __FUNCTION__, |
|
1156 '2.5.0', |
1137 /* translators: %s: get_trackback_url() */ |
1157 /* translators: %s: get_trackback_url() */ |
1138 sprintf( __( 'Use %s instead if you do not want the value echoed.' ), |
1158 sprintf( |
|
1159 __( 'Use %s instead if you do not want the value echoed.' ), |
1139 '<code>get_trackback_url()</code>' |
1160 '<code>get_trackback_url()</code>' |
1140 ) |
1161 ) |
1141 ); |
1162 ); |
1142 } |
1163 } |
1143 |
1164 |
1169 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
1190 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
1170 xmlns:dc="http://purl.org/dc/elements/1.1/" |
1191 xmlns:dc="http://purl.org/dc/elements/1.1/" |
1171 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> |
1192 xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"> |
1172 <rdf:Description rdf:about="'; |
1193 <rdf:Description rdf:about="'; |
1173 the_permalink(); |
1194 the_permalink(); |
1174 echo '"'."\n"; |
1195 echo '"' . "\n"; |
1175 echo ' dc:identifier="'; |
1196 echo ' dc:identifier="'; |
1176 the_permalink(); |
1197 the_permalink(); |
1177 echo '"'."\n"; |
1198 echo '"' . "\n"; |
1178 echo ' dc:title="'.str_replace('--', '--', wptexturize(strip_tags(get_the_title()))).'"'."\n"; |
1199 echo ' dc:title="' . str_replace( '--', '--', wptexturize( strip_tags( get_the_title() ) ) ) . '"' . "\n"; |
1179 echo ' trackback:ping="'.get_trackback_url().'"'." />\n"; |
1200 echo ' trackback:ping="' . get_trackback_url() . '"' . " />\n"; |
1180 echo '</rdf:RDF>'; |
1201 echo '</rdf:RDF>'; |
1181 } |
1202 } |
1182 |
1203 |
1183 /** |
1204 /** |
1184 * Whether the current post is open for comments. |
1205 * Determines whether the current post is open for comments. |
|
1206 * |
|
1207 * For more information on this and similar theme functions, check out |
|
1208 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1209 * Conditional Tags} article in the Theme Developer Handbook. |
1185 * |
1210 * |
1186 * @since 1.5.0 |
1211 * @since 1.5.0 |
1187 * |
1212 * |
1188 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1213 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1189 * @return bool True if the comments are open. |
1214 * @return bool True if the comments are open. |
1190 */ |
1215 */ |
1191 function comments_open( $post_id = null ) { |
1216 function comments_open( $post_id = null ) { |
1192 |
1217 |
1193 $_post = get_post($post_id); |
1218 $_post = get_post( $post_id ); |
1194 |
1219 |
1195 $post_id = $_post ? $_post->ID : 0; |
1220 $post_id = $_post ? $_post->ID : 0; |
1196 $open = ( 'open' == $_post->comment_status ); |
1221 $open = ( 'open' == $_post->comment_status ); |
1197 |
1222 |
1198 /** |
1223 /** |
1199 * Filters whether the current post is open for comments. |
1224 * Filters whether the current post is open for comments. |
1200 * |
1225 * |
1201 * @since 2.5.0 |
1226 * @since 2.5.0 |
1205 */ |
1230 */ |
1206 return apply_filters( 'comments_open', $open, $post_id ); |
1231 return apply_filters( 'comments_open', $open, $post_id ); |
1207 } |
1232 } |
1208 |
1233 |
1209 /** |
1234 /** |
1210 * Whether the current post is open for pings. |
1235 * Determines whether the current post is open for pings. |
|
1236 * |
|
1237 * For more information on this and similar theme functions, check out |
|
1238 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1239 * Conditional Tags} article in the Theme Developer Handbook. |
1211 * |
1240 * |
1212 * @since 1.5.0 |
1241 * @since 1.5.0 |
1213 * |
1242 * |
1214 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1243 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
1215 * @return bool True if pings are accepted |
1244 * @return bool True if pings are accepted |
1216 */ |
1245 */ |
1217 function pings_open( $post_id = null ) { |
1246 function pings_open( $post_id = null ) { |
1218 |
1247 |
1219 $_post = get_post($post_id); |
1248 $_post = get_post( $post_id ); |
1220 |
1249 |
1221 $post_id = $_post ? $_post->ID : 0; |
1250 $post_id = $_post ? $_post->ID : 0; |
1222 $open = ( 'open' == $_post->ping_status ); |
1251 $open = ( 'open' == $_post->ping_status ); |
1223 |
1252 |
1224 /** |
1253 /** |
1225 * Filters whether the current post is open for pings. |
1254 * Filters whether the current post is open for pings. |
1226 * |
1255 * |
1227 * @since 2.5.0 |
1256 * @since 2.5.0 |
1292 * Default false. |
1321 * Default false. |
1293 */ |
1322 */ |
1294 function comments_template( $file = '/comments.php', $separate_comments = false ) { |
1323 function comments_template( $file = '/comments.php', $separate_comments = false ) { |
1295 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
1324 global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity, $overridden_cpage; |
1296 |
1325 |
1297 if ( !(is_single() || is_page() || $withcomments) || empty($post) ) |
1326 if ( ! ( is_single() || is_page() || $withcomments ) || empty( $post ) ) { |
1298 return; |
1327 return; |
1299 |
1328 } |
1300 if ( empty($file) ) |
1329 |
|
1330 if ( empty( $file ) ) { |
1301 $file = '/comments.php'; |
1331 $file = '/comments.php'; |
1302 |
1332 } |
1303 $req = get_option('require_name_email'); |
1333 |
|
1334 $req = get_option( 'require_name_email' ); |
1304 |
1335 |
1305 /* |
1336 /* |
1306 * Comment author information fetched from the comment cookies. |
1337 * Comment author information fetched from the comment cookies. |
1307 */ |
1338 */ |
1308 $commenter = wp_get_current_commenter(); |
1339 $commenter = wp_get_current_commenter(); |
1320 $comment_author_email = $commenter['comment_author_email']; |
1351 $comment_author_email = $commenter['comment_author_email']; |
1321 |
1352 |
1322 /* |
1353 /* |
1323 * The url of the current comment author escaped for use in attributes. |
1354 * The url of the current comment author escaped for use in attributes. |
1324 */ |
1355 */ |
1325 $comment_author_url = esc_url($commenter['comment_author_url']); |
1356 $comment_author_url = esc_url( $commenter['comment_author_url'] ); |
1326 |
1357 |
1327 $comment_args = array( |
1358 $comment_args = array( |
1328 'orderby' => 'comment_date_gmt', |
1359 'orderby' => 'comment_date_gmt', |
1329 'order' => 'ASC', |
1360 'order' => 'ASC', |
1330 'status' => 'approve', |
1361 'status' => 'approve', |
1331 'post_id' => $post->ID, |
1362 'post_id' => $post->ID, |
1332 'no_found_rows' => false, |
1363 'no_found_rows' => false, |
1333 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. |
1364 'update_comment_meta_cache' => false, // We lazy-load comment meta for performance. |
1334 ); |
1365 ); |
1335 |
1366 |
1336 if ( get_option('thread_comments') ) { |
1367 if ( get_option( 'thread_comments' ) ) { |
1337 $comment_args['hierarchical'] = 'threaded'; |
1368 $comment_args['hierarchical'] = 'threaded'; |
1338 } else { |
1369 } else { |
1339 $comment_args['hierarchical'] = false; |
1370 $comment_args['hierarchical'] = false; |
1340 } |
1371 } |
1341 |
1372 |
1342 if ( $user_ID ) { |
1373 if ( $user_ID ) { |
1343 $comment_args['include_unapproved'] = array( $user_ID ); |
1374 $comment_args['include_unapproved'] = array( $user_ID ); |
1344 } elseif ( ! empty( $comment_author_email ) ) { |
1375 } else { |
1345 $comment_args['include_unapproved'] = array( $comment_author_email ); |
1376 $unapproved_email = wp_get_unapproved_comment_author_email(); |
|
1377 |
|
1378 if ( $unapproved_email ) { |
|
1379 $comment_args['include_unapproved'] = array( $unapproved_email ); |
|
1380 } |
1346 } |
1381 } |
1347 |
1382 |
1348 $per_page = 0; |
1383 $per_page = 0; |
1349 if ( get_option( 'page_comments' ) ) { |
1384 if ( get_option( 'page_comments' ) ) { |
1350 $per_page = (int) get_query_var( 'comments_per_page' ); |
1385 $per_page = (int) get_query_var( 'comments_per_page' ); |
1351 if ( 0 === $per_page ) { |
1386 if ( 0 === $per_page ) { |
1352 $per_page = (int) get_option( 'comments_per_page' ); |
1387 $per_page = (int) get_option( 'comments_per_page' ); |
1353 } |
1388 } |
1354 |
1389 |
1355 $comment_args['number'] = $per_page; |
1390 $comment_args['number'] = $per_page; |
1356 $page = (int) get_query_var( 'cpage' ); |
1391 $page = (int) get_query_var( 'cpage' ); |
1357 |
1392 |
1358 if ( $page ) { |
1393 if ( $page ) { |
1359 $comment_args['offset'] = ( $page - 1 ) * $per_page; |
1394 $comment_args['offset'] = ( $page - 1 ) * $per_page; |
1360 } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { |
1395 } elseif ( 'oldest' === get_option( 'default_comments_page' ) ) { |
1361 $comment_args['offset'] = 0; |
1396 $comment_args['offset'] = 0; |
1404 * @type bool|string $hierarchical Whether to query for comments hierarchically. |
1439 * @type bool|string $hierarchical Whether to query for comments hierarchically. |
1405 * @type int $offset Comment offset. |
1440 * @type int $offset Comment offset. |
1406 * @type int $number Number of comments to fetch. |
1441 * @type int $number Number of comments to fetch. |
1407 * } |
1442 * } |
1408 */ |
1443 */ |
1409 $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); |
1444 $comment_args = apply_filters( 'comments_template_query_args', $comment_args ); |
1410 $comment_query = new WP_Comment_Query( $comment_args ); |
1445 $comment_query = new WP_Comment_Query( $comment_args ); |
1411 $_comments = $comment_query->comments; |
1446 $_comments = $comment_query->comments; |
1412 |
1447 |
1413 // Trees must be flattened before they're passed to the walker. |
1448 // Trees must be flattened before they're passed to the walker. |
1414 if ( $comment_args['hierarchical'] ) { |
1449 if ( $comment_args['hierarchical'] ) { |
1415 $comments_flat = array(); |
1450 $comments_flat = array(); |
1416 foreach ( $_comments as $_comment ) { |
1451 foreach ( $_comments as $_comment ) { |
1417 $comments_flat[] = $_comment; |
1452 $comments_flat[] = $_comment; |
1418 $comment_children = $_comment->get_children( array( |
1453 $comment_children = $_comment->get_children( |
1419 'format' => 'flat', |
1454 array( |
1420 'status' => $comment_args['status'], |
1455 'format' => 'flat', |
1421 'orderby' => $comment_args['orderby'] |
1456 'status' => $comment_args['status'], |
1422 ) ); |
1457 'orderby' => $comment_args['orderby'], |
|
1458 ) |
|
1459 ); |
1423 |
1460 |
1424 foreach ( $comment_children as $comment_child ) { |
1461 foreach ( $comment_children as $comment_child ) { |
1425 $comments_flat[] = $comment_child; |
1462 $comments_flat[] = $comment_child; |
1426 } |
1463 } |
1427 } |
1464 } |
1437 * @param array $comments Array of comments supplied to the comments template. |
1474 * @param array $comments Array of comments supplied to the comments template. |
1438 * @param int $post_ID Post ID. |
1475 * @param int $post_ID Post ID. |
1439 */ |
1476 */ |
1440 $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); |
1477 $wp_query->comments = apply_filters( 'comments_array', $comments_flat, $post->ID ); |
1441 |
1478 |
1442 $comments = &$wp_query->comments; |
1479 $comments = &$wp_query->comments; |
1443 $wp_query->comment_count = count($wp_query->comments); |
1480 $wp_query->comment_count = count( $wp_query->comments ); |
1444 $wp_query->max_num_comment_pages = $comment_query->max_num_pages; |
1481 $wp_query->max_num_comment_pages = $comment_query->max_num_pages; |
1445 |
1482 |
1446 if ( $separate_comments ) { |
1483 if ( $separate_comments ) { |
1447 $wp_query->comments_by_type = separate_comments($comments); |
1484 $wp_query->comments_by_type = separate_comments( $comments ); |
1448 $comments_by_type = &$wp_query->comments_by_type; |
1485 $comments_by_type = &$wp_query->comments_by_type; |
1449 } else { |
1486 } else { |
1450 $wp_query->comments_by_type = array(); |
1487 $wp_query->comments_by_type = array(); |
1451 } |
1488 } |
1452 |
1489 |
1453 $overridden_cpage = false; |
1490 $overridden_cpage = false; |
1454 if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { |
1491 if ( '' == get_query_var( 'cpage' ) && $wp_query->max_num_comment_pages > 1 ) { |
1455 set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
1492 set_query_var( 'cpage', 'newest' == get_option( 'default_comments_page' ) ? get_comment_pages_count() : 1 ); |
1456 $overridden_cpage = true; |
1493 $overridden_cpage = true; |
1457 } |
1494 } |
1458 |
1495 |
1459 if ( !defined('COMMENTS_TEMPLATE') ) |
1496 if ( ! defined( 'COMMENTS_TEMPLATE' ) ) { |
1460 define('COMMENTS_TEMPLATE', true); |
1497 define( 'COMMENTS_TEMPLATE', true ); |
|
1498 } |
1461 |
1499 |
1462 $theme_template = STYLESHEETPATH . $file; |
1500 $theme_template = STYLESHEETPATH . $file; |
1463 /** |
1501 /** |
1464 * Filters the path to the theme template file used for the comments template. |
1502 * Filters the path to the theme template file used for the comments template. |
1465 * |
1503 * |
1466 * @since 1.5.1 |
1504 * @since 1.5.1 |
1467 * |
1505 * |
1468 * @param string $theme_template The path to the theme template file. |
1506 * @param string $theme_template The path to the theme template file. |
1469 */ |
1507 */ |
1470 $include = apply_filters( 'comments_template', $theme_template ); |
1508 $include = apply_filters( 'comments_template', $theme_template ); |
1471 if ( file_exists( $include ) ) |
1509 if ( file_exists( $include ) ) { |
1472 require( $include ); |
1510 require( $include ); |
1473 elseif ( file_exists( TEMPLATEPATH . $file ) ) |
1511 } elseif ( file_exists( TEMPLATEPATH . $file ) ) { |
1474 require( TEMPLATEPATH . $file ); |
1512 require( TEMPLATEPATH . $file ); |
1475 else // Backward compat code will be removed in a future release |
1513 } else { // Backward compat code will be removed in a future release |
1476 require( ABSPATH . WPINC . '/theme-compat/comments.php'); |
1514 require( ABSPATH . WPINC . '/theme-compat/comments.php' ); |
|
1515 } |
1477 } |
1516 } |
1478 |
1517 |
1479 /** |
1518 /** |
1480 * Displays the link to the comments for the current post ID. |
1519 * Displays the link to the comments for the current post ID. |
1481 * |
1520 * |
1482 * @since 0.71 |
1521 * @since 0.71 |
1483 * |
1522 * |
1484 * @param string $zero Optional. String to display when no comments. Default false. |
1523 * @param false|string $zero Optional. String to display when no comments. Default false. |
1485 * @param string $one Optional. String to display when only one comment is available. |
1524 * @param false|string $one Optional. String to display when only one comment is available. Default false. |
1486 * Default false. |
1525 * @param false|string $more Optional. String to display when there are more than one comment. Default false. |
1487 * @param string $more Optional. String to display when there are more than one comment. |
1526 * @param string $css_class Optional. CSS class to use for comments. Default empty. |
1488 * Default false. |
1527 * @param false|string $none Optional. String to display when comments have been turned off. Default false. |
1489 * @param string $css_class Optional. CSS class to use for comments. Default empty. |
|
1490 * @param string $none Optional. String to display when comments have been turned off. |
|
1491 * Default false. |
|
1492 */ |
1528 */ |
1493 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
1529 function comments_popup_link( $zero = false, $one = false, $more = false, $css_class = '', $none = false ) { |
1494 $id = get_the_ID(); |
1530 $id = get_the_ID(); |
1495 $title = get_the_title(); |
1531 $title = get_the_title(); |
1496 $number = get_comments_number( $id ); |
1532 $number = get_comments_number( $id ); |
1497 |
1533 |
1498 if ( false === $zero ) { |
1534 if ( false === $zero ) { |
1499 /* translators: %s: post title */ |
1535 /* translators: %s: post title */ |
1500 $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
1536 $zero = sprintf( __( 'No Comments<span class="screen-reader-text"> on %s</span>' ), $title ); |
1504 /* translators: %s: post title */ |
1540 /* translators: %s: post title */ |
1505 $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
1541 $one = sprintf( __( '1 Comment<span class="screen-reader-text"> on %s</span>' ), $title ); |
1506 } |
1542 } |
1507 |
1543 |
1508 if ( false === $more ) { |
1544 if ( false === $more ) { |
1509 /* translators: 1: Number of comments 2: post title */ |
1545 /* translators: 1: number of comments, 2: post title */ |
1510 $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 ); |
1546 $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 ); |
1511 $more = sprintf( $more, number_format_i18n( $number ), $title ); |
1547 $more = sprintf( $more, number_format_i18n( $number ), $title ); |
1512 } |
1548 } |
1513 |
1549 |
1514 if ( false === $none ) { |
1550 if ( false === $none ) { |
1515 /* translators: %s: post title */ |
1551 /* translators: %s: post title */ |
1516 $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
1552 $none = sprintf( __( 'Comments Off<span class="screen-reader-text"> on %s</span>' ), $title ); |
1517 } |
1553 } |
1518 |
1554 |
1519 if ( 0 == $number && !comments_open() && !pings_open() ) { |
1555 if ( 0 == $number && ! comments_open() && ! pings_open() ) { |
1520 echo '<span' . ((!empty($css_class)) ? ' class="' . esc_attr( $css_class ) . '"' : '') . '>' . $none . '</span>'; |
1556 echo '<span' . ( ( ! empty( $css_class ) ) ? ' class="' . esc_attr( $css_class ) . '"' : '' ) . '>' . $none . '</span>'; |
1521 return; |
1557 return; |
1522 } |
1558 } |
1523 |
1559 |
1524 if ( post_password_required() ) { |
1560 if ( post_password_required() ) { |
1525 _e( 'Enter your password to view comments.' ); |
1561 _e( 'Enter your password to view comments.' ); |
1593 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
1629 function get_comment_reply_link( $args = array(), $comment = null, $post = null ) { |
1594 $defaults = array( |
1630 $defaults = array( |
1595 'add_below' => 'comment', |
1631 'add_below' => 'comment', |
1596 'respond_id' => 'respond', |
1632 'respond_id' => 'respond', |
1597 'reply_text' => __( 'Reply' ), |
1633 'reply_text' => __( 'Reply' ), |
1598 /* translators: Comment reply button text. 1: Comment author name */ |
1634 /* translators: Comment reply button text. %s: Comment author name */ |
1599 'reply_to_text' => __( 'Reply to %s' ), |
1635 'reply_to_text' => __( 'Reply to %s' ), |
1600 'login_text' => __( 'Log in to Reply' ), |
1636 'login_text' => __( 'Log in to Reply' ), |
1601 'max_depth' => 0, |
1637 'max_depth' => 0, |
1602 'depth' => 0, |
1638 'depth' => 0, |
1603 'before' => '', |
1639 'before' => '', |
1604 'after' => '' |
1640 'after' => '', |
1605 ); |
1641 ); |
1606 |
1642 |
1607 $args = wp_parse_args( $args, $defaults ); |
1643 $args = wp_parse_args( $args, $defaults ); |
1608 |
1644 |
1609 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
1645 if ( 0 == $args['depth'] || $args['max_depth'] <= $args['depth'] ) { |
1633 * @param WP_Post $post The WP_Post object. |
1669 * @param WP_Post $post The WP_Post object. |
1634 */ |
1670 */ |
1635 $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
1671 $args = apply_filters( 'comment_reply_link_args', $args, $comment, $post ); |
1636 |
1672 |
1637 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
1673 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
1638 $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
1674 $link = sprintf( |
|
1675 '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
1639 esc_url( wp_login_url( get_permalink() ) ), |
1676 esc_url( wp_login_url( get_permalink() ) ), |
1640 $args['login_text'] |
1677 $args['login_text'] |
1641 ); |
1678 ); |
1642 } else { |
1679 } else { |
1643 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )', |
1680 $data_attributes = array( |
1644 $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID |
1681 'commentid' => $comment->comment_ID, |
|
1682 'postid' => $post->ID, |
|
1683 'belowelement' => $args['add_below'] . '-' . $comment->comment_ID, |
|
1684 'respondelement' => $args['respond_id'], |
1645 ); |
1685 ); |
1646 |
1686 |
1647 $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>", |
1687 $data_attribute_string = ''; |
1648 esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . "#" . $args['respond_id'], |
1688 |
1649 $onclick, |
1689 foreach ( $data_attributes as $name => $value ) { |
|
1690 $data_attribute_string .= " data-${name}=\"" . esc_attr( $value ) . '"'; |
|
1691 } |
|
1692 |
|
1693 $data_attribute_string = trim( $data_attribute_string ); |
|
1694 |
|
1695 $link = sprintf( |
|
1696 "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>", |
|
1697 esc_url( |
|
1698 add_query_arg( |
|
1699 array( |
|
1700 'replytocom' => $comment->comment_ID, |
|
1701 'unapproved' => false, |
|
1702 'moderation-hash' => false, |
|
1703 ) |
|
1704 ) |
|
1705 ) . '#' . $args['respond_id'], |
|
1706 $data_attribute_string, |
1650 esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
1707 esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ), |
1651 $args['reply_text'] |
1708 $args['reply_text'] |
1652 ); |
1709 ); |
1653 } |
1710 } |
1654 |
1711 |
1676 * @param int $comment Comment being replied to. Default current comment. |
1733 * @param int $comment Comment being replied to. Default current comment. |
1677 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
1734 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
1678 * Default current post. |
1735 * Default current post. |
1679 * @return mixed Link to show comment form, if successful. False, if comments are closed. |
1736 * @return mixed Link to show comment form, if successful. False, if comments are closed. |
1680 */ |
1737 */ |
1681 function comment_reply_link($args = array(), $comment = null, $post = null) { |
1738 function comment_reply_link( $args = array(), $comment = null, $post = null ) { |
1682 echo get_comment_reply_link($args, $comment, $post); |
1739 echo get_comment_reply_link( $args, $comment, $post ); |
1683 } |
1740 } |
1684 |
1741 |
1685 /** |
1742 /** |
1686 * Retrieve HTML content for reply to post link. |
1743 * Retrieve HTML content for reply to post link. |
1687 * |
1744 * |
1703 * } |
1760 * } |
1704 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. |
1761 * @param int|WP_Post $post Optional. Post ID or WP_Post object the comment is going to be displayed on. |
1705 * Default current post. |
1762 * Default current post. |
1706 * @return false|null|string Link to show comment form, if successful. False, if comments are closed. |
1763 * @return false|null|string Link to show comment form, if successful. False, if comments are closed. |
1707 */ |
1764 */ |
1708 function get_post_reply_link($args = array(), $post = null) { |
1765 function get_post_reply_link( $args = array(), $post = null ) { |
1709 $defaults = array( |
1766 $defaults = array( |
1710 'add_below' => 'post', |
1767 'add_below' => 'post', |
1711 'respond_id' => 'respond', |
1768 'respond_id' => 'respond', |
1712 'reply_text' => __('Leave a Comment'), |
1769 'reply_text' => __( 'Leave a Comment' ), |
1713 'login_text' => __('Log in to leave a Comment'), |
1770 'login_text' => __( 'Log in to leave a Comment' ), |
1714 'before' => '', |
1771 'before' => '', |
1715 'after' => '', |
1772 'after' => '', |
1716 ); |
1773 ); |
1717 |
1774 |
1718 $args = wp_parse_args($args, $defaults); |
1775 $args = wp_parse_args( $args, $defaults ); |
1719 |
1776 |
1720 $post = get_post($post); |
1777 $post = get_post( $post ); |
1721 |
1778 |
1722 if ( ! comments_open( $post->ID ) ) { |
1779 if ( ! comments_open( $post->ID ) ) { |
1723 return false; |
1780 return false; |
1724 } |
1781 } |
1725 |
1782 |
1726 if ( get_option('comment_registration') && ! is_user_logged_in() ) { |
1783 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) { |
1727 $link = sprintf( '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
1784 $link = sprintf( |
|
1785 '<a rel="nofollow" class="comment-reply-login" href="%s">%s</a>', |
1728 wp_login_url( get_permalink() ), |
1786 wp_login_url( get_permalink() ), |
1729 $args['login_text'] |
1787 $args['login_text'] |
1730 ); |
1788 ); |
1731 } else { |
1789 } else { |
1732 $onclick = sprintf( 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
1790 $onclick = sprintf( |
1733 $args['add_below'], $post->ID, $args['respond_id'] |
1791 'return addComment.moveForm( "%1$s-%2$s", "0", "%3$s", "%2$s" )', |
|
1792 $args['add_below'], |
|
1793 $post->ID, |
|
1794 $args['respond_id'] |
1734 ); |
1795 ); |
1735 |
1796 |
1736 $link = sprintf( "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
1797 $link = sprintf( |
|
1798 "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s'>%s</a>", |
1737 get_permalink( $post->ID ) . '#' . $args['respond_id'], |
1799 get_permalink( $post->ID ) . '#' . $args['respond_id'], |
1738 $onclick, |
1800 $onclick, |
1739 $args['reply_text'] |
1801 $args['reply_text'] |
1740 ); |
1802 ); |
1741 } |
1803 } |
1762 * @param array $args Optional. Override default options, |
1824 * @param array $args Optional. Override default options, |
1763 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
1825 * @param int|WP_Post $post Post ID or WP_Post object the comment is going to be displayed on. |
1764 * Default current post. |
1826 * Default current post. |
1765 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
1827 * @return string|bool|null Link to show comment form, if successful. False, if comments are closed. |
1766 */ |
1828 */ |
1767 function post_reply_link($args = array(), $post = null) { |
1829 function post_reply_link( $args = array(), $post = null ) { |
1768 echo get_post_reply_link($args, $post); |
1830 echo get_post_reply_link( $args, $post ); |
1769 } |
1831 } |
1770 |
1832 |
1771 /** |
1833 /** |
1772 * Retrieve HTML content for cancel comment reply link. |
1834 * Retrieve HTML content for cancel comment reply link. |
1773 * |
1835 * |
1868 * to their comment. Default true. |
1932 * to their comment. Default true. |
1869 */ |
1933 */ |
1870 function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
1934 function comment_form_title( $noreplytext = false, $replytext = false, $linktoparent = true ) { |
1871 global $comment; |
1935 global $comment; |
1872 |
1936 |
1873 if ( false === $noreplytext ) $noreplytext = __( 'Leave a Reply' ); |
1937 if ( false === $noreplytext ) { |
1874 if ( false === $replytext ) $replytext = __( 'Leave a Reply to %s' ); |
1938 $noreplytext = __( 'Leave a Reply' ); |
1875 |
1939 } |
1876 $replytoid = isset($_GET['replytocom']) ? (int) $_GET['replytocom'] : 0; |
1940 if ( false === $replytext ) { |
1877 |
1941 $replytext = __( 'Leave a Reply to %s' ); |
1878 if ( 0 == $replytoid ) |
1942 } |
|
1943 |
|
1944 $replytoid = isset( $_GET['replytocom'] ) ? (int) $_GET['replytocom'] : 0; |
|
1945 |
|
1946 if ( 0 == $replytoid ) { |
1879 echo $noreplytext; |
1947 echo $noreplytext; |
1880 else { |
1948 } else { |
1881 // Sets the global so that template tags can be used in the comment form. |
1949 // Sets the global so that template tags can be used in the comment form. |
1882 $comment = get_comment($replytoid); |
1950 $comment = get_comment( $replytoid ); |
1883 $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
1951 $author = ( $linktoparent ) ? '<a href="#comment-' . get_comment_ID() . '">' . get_comment_author( $comment ) . '</a>' : get_comment_author( $comment ); |
1884 printf( $replytext, $author ); |
1952 printf( $replytext, $author ); |
1885 } |
1953 } |
1886 } |
1954 } |
1887 |
1955 |
1888 /** |
1956 /** |
1962 $r = apply_filters( 'wp_list_comments_args', $r ); |
2030 $r = apply_filters( 'wp_list_comments_args', $r ); |
1963 |
2031 |
1964 // Figure out what comments we'll be looping through ($_comments) |
2032 // Figure out what comments we'll be looping through ($_comments) |
1965 if ( null !== $comments ) { |
2033 if ( null !== $comments ) { |
1966 $comments = (array) $comments; |
2034 $comments = (array) $comments; |
1967 if ( empty($comments) ) |
2035 if ( empty( $comments ) ) { |
1968 return; |
2036 return; |
|
2037 } |
1969 if ( 'all' != $r['type'] ) { |
2038 if ( 'all' != $r['type'] ) { |
1970 $comments_by_type = separate_comments($comments); |
2039 $comments_by_type = separate_comments( $comments ); |
1971 if ( empty($comments_by_type[$r['type']]) ) |
2040 if ( empty( $comments_by_type[ $r['type'] ] ) ) { |
1972 return; |
2041 return; |
1973 $_comments = $comments_by_type[$r['type']]; |
2042 } |
|
2043 $_comments = $comments_by_type[ $r['type'] ]; |
1974 } else { |
2044 } else { |
1975 $_comments = $comments; |
2045 $_comments = $comments; |
1976 } |
2046 } |
1977 } else { |
2047 } else { |
1978 /* |
2048 /* |
1988 $current_per_page = get_query_var( 'comments_per_page' ); |
2058 $current_per_page = get_query_var( 'comments_per_page' ); |
1989 if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { |
2059 if ( $r['page'] != $current_cpage || $r['per_page'] != $current_per_page ) { |
1990 $comment_args = array( |
2060 $comment_args = array( |
1991 'post_id' => get_the_ID(), |
2061 'post_id' => get_the_ID(), |
1992 'orderby' => 'comment_date_gmt', |
2062 'orderby' => 'comment_date_gmt', |
1993 'order' => 'ASC', |
2063 'order' => 'ASC', |
1994 'status' => 'approve', |
2064 'status' => 'approve', |
1995 ); |
2065 ); |
1996 |
2066 |
1997 if ( is_user_logged_in() ) { |
2067 if ( is_user_logged_in() ) { |
1998 $comment_args['include_unapproved'] = get_current_user_id(); |
2068 $comment_args['include_unapproved'] = get_current_user_id(); |
1999 } else { |
2069 } else { |
2000 $commenter = wp_get_current_commenter(); |
2070 $unapproved_email = wp_get_unapproved_comment_author_email(); |
2001 if ( $commenter['comment_author_email'] ) { |
2071 |
2002 $comment_args['include_unapproved'] = $commenter['comment_author_email']; |
2072 if ( $unapproved_email ) { |
|
2073 $comment_args['include_unapproved'] = array( $unapproved_email ); |
2003 } |
2074 } |
2004 } |
2075 } |
2005 |
2076 |
2006 $comments = get_comments( $comment_args ); |
2077 $comments = get_comments( $comment_args ); |
2007 |
2078 |
2015 } else { |
2086 } else { |
2016 $_comments = $comments; |
2087 $_comments = $comments; |
2017 } |
2088 } |
2018 } |
2089 } |
2019 |
2090 |
2020 // Otherwise, fall back on the comments from `$wp_query->comments`. |
2091 // Otherwise, fall back on the comments from `$wp_query->comments`. |
2021 } else { |
2092 } else { |
2022 if ( empty($wp_query->comments) ) |
2093 if ( empty( $wp_query->comments ) ) { |
2023 return; |
2094 return; |
|
2095 } |
2024 if ( 'all' != $r['type'] ) { |
2096 if ( 'all' != $r['type'] ) { |
2025 if ( empty($wp_query->comments_by_type) ) |
2097 if ( empty( $wp_query->comments_by_type ) ) { |
2026 $wp_query->comments_by_type = separate_comments($wp_query->comments); |
2098 $wp_query->comments_by_type = separate_comments( $wp_query->comments ); |
2027 if ( empty($wp_query->comments_by_type[$r['type']]) ) |
2099 } |
|
2100 if ( empty( $wp_query->comments_by_type[ $r['type'] ] ) ) { |
2028 return; |
2101 return; |
2029 $_comments = $wp_query->comments_by_type[$r['type']]; |
2102 } |
|
2103 $_comments = $wp_query->comments_by_type[ $r['type'] ]; |
2030 } else { |
2104 } else { |
2031 $_comments = $wp_query->comments; |
2105 $_comments = $wp_query->comments; |
2032 } |
2106 } |
2033 |
2107 |
2034 if ( $wp_query->max_num_comment_pages ) { |
2108 if ( $wp_query->max_num_comment_pages ) { |
2035 $default_comments_page = get_option( 'default_comments_page' ); |
2109 $default_comments_page = get_option( 'default_comments_page' ); |
2036 $cpage = get_query_var( 'cpage' ); |
2110 $cpage = get_query_var( 'cpage' ); |
2037 if ( 'newest' === $default_comments_page ) { |
2111 if ( 'newest' === $default_comments_page ) { |
2038 $r['cpage'] = $cpage; |
2112 $r['cpage'] = $cpage; |
2039 |
2113 |
2040 /* |
2114 /* |
2041 * When first page shows oldest comments, post permalink is the same as |
2115 * When first page shows oldest comments, post permalink is the same as |
2042 * the comment permalink. |
2116 * the comment permalink. |
2043 */ |
2117 */ |
2044 } elseif ( $cpage == 1 ) { |
2118 } elseif ( $cpage == 1 ) { |
2045 $r['cpage'] = ''; |
2119 $r['cpage'] = ''; |
2046 } else { |
2120 } else { |
2047 $r['cpage'] = $cpage; |
2121 $r['cpage'] = $cpage; |
2048 } |
2122 } |
2049 |
2123 |
2050 $r['page'] = 0; |
2124 $r['page'] = 0; |
2051 $r['per_page'] = 0; |
2125 $r['per_page'] = 0; |
2052 } |
2126 } |
2053 } |
2127 } |
2054 } |
2128 } |
2055 |
2129 |
2056 if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { |
2130 if ( '' === $r['per_page'] && get_option( 'page_comments' ) ) { |
2057 $r['per_page'] = get_query_var('comments_per_page'); |
2131 $r['per_page'] = get_query_var( 'comments_per_page' ); |
2058 } |
2132 } |
2059 |
2133 |
2060 if ( empty($r['per_page']) ) { |
2134 if ( empty( $r['per_page'] ) ) { |
2061 $r['per_page'] = 0; |
2135 $r['per_page'] = 0; |
2062 $r['page'] = 0; |
2136 $r['page'] = 0; |
2063 } |
2137 } |
2064 |
2138 |
2065 if ( '' === $r['max_depth'] ) { |
2139 if ( '' === $r['max_depth'] ) { |
2066 if ( get_option('thread_comments') ) |
2140 if ( get_option( 'thread_comments' ) ) { |
2067 $r['max_depth'] = get_option('thread_comments_depth'); |
2141 $r['max_depth'] = get_option( 'thread_comments_depth' ); |
2068 else |
2142 } else { |
2069 $r['max_depth'] = -1; |
2143 $r['max_depth'] = -1; |
|
2144 } |
2070 } |
2145 } |
2071 |
2146 |
2072 if ( '' === $r['page'] ) { |
2147 if ( '' === $r['page'] ) { |
2073 if ( empty($overridden_cpage) ) { |
2148 if ( empty( $overridden_cpage ) ) { |
2074 $r['page'] = get_query_var('cpage'); |
2149 $r['page'] = get_query_var( 'cpage' ); |
2075 } else { |
2150 } else { |
2076 $threaded = ( -1 != $r['max_depth'] ); |
2151 $threaded = ( -1 != $r['max_depth'] ); |
2077 $r['page'] = ( 'newest' == get_option('default_comments_page') ) ? get_comment_pages_count($_comments, $r['per_page'], $threaded) : 1; |
2152 $r['page'] = ( 'newest' == get_option( 'default_comments_page' ) ) ? get_comment_pages_count( $_comments, $r['per_page'], $threaded ) : 1; |
2078 set_query_var( 'cpage', $r['page'] ); |
2153 set_query_var( 'cpage', $r['page'] ); |
2079 } |
2154 } |
2080 } |
2155 } |
2081 // Validation check |
2156 // Validation check |
2082 $r['page'] = intval($r['page']); |
2157 $r['page'] = intval( $r['page'] ); |
2083 if ( 0 == $r['page'] && 0 != $r['per_page'] ) |
2158 if ( 0 == $r['page'] && 0 != $r['per_page'] ) { |
2084 $r['page'] = 1; |
2159 $r['page'] = 1; |
2085 |
2160 } |
2086 if ( null === $r['reverse_top_level'] ) |
2161 |
2087 $r['reverse_top_level'] = ( 'desc' == get_option('comment_order') ); |
2162 if ( null === $r['reverse_top_level'] ) { |
|
2163 $r['reverse_top_level'] = ( 'desc' == get_option( 'comment_order' ) ); |
|
2164 } |
2088 |
2165 |
2089 wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
2166 wp_queue_comments_for_comment_meta_lazyload( $_comments ); |
2090 |
2167 |
2091 if ( empty( $r['walker'] ) ) { |
2168 if ( empty( $r['walker'] ) ) { |
2092 $walker = new Walker_Comment; |
2169 $walker = new Walker_Comment; |
2168 * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. |
2245 * @type string $format The comment form format. Default 'xhtml'. Accepts 'xhtml', 'html5'. |
2169 * } |
2246 * } |
2170 * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
2247 * @param int|WP_Post $post_id Post ID or WP_Post object to generate the form for. Default current post. |
2171 */ |
2248 */ |
2172 function comment_form( $args = array(), $post_id = null ) { |
2249 function comment_form( $args = array(), $post_id = null ) { |
2173 if ( null === $post_id ) |
2250 if ( null === $post_id ) { |
2174 $post_id = get_the_ID(); |
2251 $post_id = get_the_ID(); |
|
2252 } |
2175 |
2253 |
2176 // Exit the function when comments for the post are closed. |
2254 // Exit the function when comments for the post are closed. |
2177 if ( ! comments_open( $post_id ) ) { |
2255 if ( ! comments_open( $post_id ) ) { |
2178 /** |
2256 /** |
2179 * Fires after the comment form if comments are closed. |
2257 * Fires after the comment form if comments are closed. |
2183 do_action( 'comment_form_comments_closed' ); |
2261 do_action( 'comment_form_comments_closed' ); |
2184 |
2262 |
2185 return; |
2263 return; |
2186 } |
2264 } |
2187 |
2265 |
2188 $commenter = wp_get_current_commenter(); |
2266 $commenter = wp_get_current_commenter(); |
2189 $user = wp_get_current_user(); |
2267 $user = wp_get_current_user(); |
2190 $user_identity = $user->exists() ? $user->display_name : ''; |
2268 $user_identity = $user->exists() ? $user->display_name : ''; |
2191 |
2269 |
2192 $args = wp_parse_args( $args ); |
2270 $args = wp_parse_args( $args ); |
2193 if ( ! isset( $args['format'] ) ) |
2271 if ( ! isset( $args['format'] ) ) { |
2194 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
2272 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
|
2273 } |
2195 |
2274 |
2196 $req = get_option( 'require_name_email' ); |
2275 $req = get_option( 'require_name_email' ); |
2197 $html_req = ( $req ? " required='required'" : '' ); |
2276 $html_req = ( $req ? " required='required'" : '' ); |
2198 $html5 = 'html5' === $args['format']; |
2277 $html5 = 'html5' === $args['format']; |
2199 $fields = array( |
2278 $fields = array( |
2200 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2279 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2201 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>', |
2280 '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" maxlength="245"' . $html_req . ' /></p>', |
2202 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2281 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . ( $req ? ' <span class="required">*</span>' : '' ) . '</label> ' . |
2203 '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>', |
2282 '<input id="email" name="email" ' . ( $html5 ? 'type="email"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" maxlength="100" aria-describedby="email-notes"' . $html_req . ' /></p>', |
2204 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
2283 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label> ' . |
2205 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
2284 '<input id="url" name="url" ' . ( $html5 ? 'type="url"' : 'type="text"' ) . ' value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" maxlength="200" /></p>', |
2206 ); |
2285 ); |
2207 |
2286 |
2208 if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
2287 if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
2209 $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; |
2288 $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; |
2221 /** |
2300 /** |
2222 * Filters the default comment form fields. |
2301 * Filters the default comment form fields. |
2223 * |
2302 * |
2224 * @since 3.0.0 |
2303 * @since 3.0.0 |
2225 * |
2304 * |
2226 * @param array $fields The default comment fields. |
2305 * @param string[] $fields Array of the default comment fields. |
2227 */ |
2306 */ |
2228 $fields = apply_filters( 'comment_form_default_fields', $fields ); |
2307 $fields = apply_filters( 'comment_form_default_fields', $fields ); |
2229 $defaults = array( |
2308 $defaults = array( |
2230 'fields' => $fields, |
2309 'fields' => $fields, |
2231 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>', |
2310 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea></p>', |
2232 /** This filter is documented in wp-includes/link-template.php */ |
2311 /** This filter is documented in wp-includes/link-template.php */ |
2233 'must_log_in' => '<p class="must-log-in">' . sprintf( |
2312 'must_log_in' => '<p class="must-log-in">' . sprintf( |
2234 /* translators: %s: login URL */ |
2313 /* translators: %s: login URL */ |
2235 __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
2314 __( 'You must be <a href="%s">logged in</a> to post a comment.' ), |
2236 wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2315 wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2237 ) . '</p>', |
2316 ) . '</p>', |
2238 /** This filter is documented in wp-includes/link-template.php */ |
2317 /** This filter is documented in wp-includes/link-template.php */ |
2239 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
2318 'logged_in_as' => '<p class="logged-in-as">' . sprintf( |
2240 /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
2319 /* translators: 1: edit user link, 2: accessibility text, 3: user name, 4: logout URL */ |
2241 __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
2320 __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
2242 get_edit_user_link(), |
2321 get_edit_user_link(), |
2243 /* translators: %s: user name */ |
2322 /* translators: %s: user name */ |
2244 esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
2323 esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
2245 $user_identity, |
2324 $user_identity, |
2246 wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2325 wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2247 ) . '</p>', |
2326 ) . '</p>', |
2248 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>'. ( $req ? $required_text : '' ) . '</p>', |
2327 'comment_notes_before' => '<p class="comment-notes"><span id="email-notes">' . __( 'Your email address will not be published.' ) . '</span>' . ( $req ? $required_text : '' ) . '</p>', |
2249 'comment_notes_after' => '', |
2328 'comment_notes_after' => '', |
2250 'action' => site_url( '/wp-comments-post.php' ), |
2329 'action' => site_url( '/wp-comments-post.php' ), |
2251 'id_form' => 'commentform', |
2330 'id_form' => 'commentform', |
2252 'id_submit' => 'submit', |
2331 'id_submit' => 'submit', |
2253 'class_form' => 'comment-form', |
2332 'class_form' => 'comment-form', |
2299 |
2378 |
2300 echo $args['cancel_reply_after']; |
2379 echo $args['cancel_reply_after']; |
2301 |
2380 |
2302 echo $args['title_reply_after']; |
2381 echo $args['title_reply_after']; |
2303 |
2382 |
2304 if ( get_option( 'comment_registration' ) && !is_user_logged_in() ) : |
2383 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) : |
2305 echo $args['must_log_in']; |
2384 echo $args['must_log_in']; |
2306 /** |
2385 /** |
2307 * Fires after the HTML-formatted 'must log in after' message in the comment form. |
2386 * Fires after the HTML-formatted 'must log in after' message in the comment form. |
2308 * |
2387 * |
2309 * @since 3.0.0 |
2388 * @since 3.0.0 |
2310 */ |
2389 */ |
2311 do_action( 'comment_form_must_log_in_after' ); |
2390 do_action( 'comment_form_must_log_in_after' ); |
2312 else : ?> |
2391 else : |
|
2392 ?> |
2313 <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
2393 <form action="<?php echo esc_url( $args['action'] ); ?>" method="post" id="<?php echo esc_attr( $args['id_form'] ); ?>" class="<?php echo esc_attr( $args['class_form'] ); ?>"<?php echo $html5 ? ' novalidate' : ''; ?>> |
2314 <?php |
2394 <?php |
2315 /** |
2395 /** |
2316 * Fires at the top of the comment form, inside the form tag. |
2396 * Fires at the top of the comment form, inside the form tag. |
2317 * |
2397 * |