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 $comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : $comment_ID; |
26 |
27 |
27 if ( empty( $comment->comment_author ) ) { |
28 if ( empty( $comment->comment_author ) ) { |
28 $user = $comment->user_id ? get_userdata( $comment->user_id ) : false; |
29 $user = ! empty( $comment->user_id ) ? get_userdata( $comment->user_id ) : false; |
29 if ( $user ) { |
30 if ( $user ) { |
30 $author = $user->display_name; |
31 $author = $user->display_name; |
31 } else { |
32 } else { |
32 $author = __( 'Anonymous' ); |
33 $author = __( 'Anonymous' ); |
33 } |
34 } |
40 * |
41 * |
41 * @since 1.5.0 |
42 * @since 1.5.0 |
42 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
43 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
43 * |
44 * |
44 * @param string $author The comment author's username. |
45 * @param string $author The comment author's username. |
45 * @param int $comment_ID The comment ID. |
46 * @param string $comment_ID The comment ID as a numeric string. |
46 * @param WP_Comment $comment The comment object. |
47 * @param WP_Comment $comment The comment object. |
47 */ |
48 */ |
48 return apply_filters( 'get_comment_author', $author, $comment->comment_ID, $comment ); |
49 return apply_filters( 'get_comment_author', $author, $comment_ID, $comment ); |
49 } |
50 } |
50 |
51 |
51 /** |
52 /** |
52 * Displays the author of the current comment. |
53 * Displays the author of the current comment. |
53 * |
54 * |
91 * |
92 * |
92 * @since 1.5.0 |
93 * @since 1.5.0 |
93 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
94 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
94 * |
95 * |
95 * @param string $comment_author_email The comment author's email address. |
96 * @param string $comment_author_email The comment author's email address. |
96 * @param int $comment_ID The comment ID. |
97 * @param string $comment_ID The comment ID as a numeric string. |
97 * @param WP_Comment $comment The comment object. |
98 * @param WP_Comment $comment The comment object. |
98 */ |
99 */ |
99 return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); |
100 return apply_filters( 'get_comment_author_email', $comment->comment_author_email, $comment->comment_ID, $comment ); |
100 } |
101 } |
101 |
102 |
234 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added. |
235 * @since 4.1.0 The `$author` and `$comment_ID` parameters were added. |
235 * |
236 * |
236 * @param string $return The HTML-formatted comment author link. |
237 * @param string $return The HTML-formatted comment author link. |
237 * Empty for an invalid URL. |
238 * Empty for an invalid URL. |
238 * @param string $author The comment author's username. |
239 * @param string $author The comment author's username. |
239 * @param int $comment_ID The comment ID. |
240 * @param string $comment_ID The comment ID as a numeric string. |
240 */ |
241 */ |
241 return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); |
242 return apply_filters( 'get_comment_author_link', $return, $author, $comment->comment_ID ); |
242 } |
243 } |
243 |
244 |
244 /** |
245 /** |
253 function comment_author_link( $comment_ID = 0 ) { |
254 function comment_author_link( $comment_ID = 0 ) { |
254 echo get_comment_author_link( $comment_ID ); |
255 echo get_comment_author_link( $comment_ID ); |
255 } |
256 } |
256 |
257 |
257 /** |
258 /** |
258 * Retrieve the IP address of the author of the current comment. |
259 * Retrieves the IP address of the author of the current comment. |
259 * |
260 * |
260 * @since 1.5.0 |
261 * @since 1.5.0 |
261 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
262 * @since 4.4.0 Added the ability for `$comment_ID` to also accept a WP_Comment object. |
262 * |
263 * |
263 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
264 * @param int|WP_Comment $comment_ID Optional. WP_Comment or the ID of the comment for which to get the author's IP address. |
264 * Default current comment. |
265 * Default current comment. |
265 * @return string Comment author's IP address. |
266 * @return string Comment author's IP address, or an empty string if it's not available. |
266 */ |
267 */ |
267 function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
268 function get_comment_author_IP( $comment_ID = 0 ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
268 $comment = get_comment( $comment_ID ); |
269 $comment = get_comment( $comment_ID ); |
269 |
270 |
270 /** |
271 /** |
271 * Filters the comment author's returned IP address. |
272 * Filters the comment author's returned IP address. |
272 * |
273 * |
273 * @since 1.5.0 |
274 * @since 1.5.0 |
274 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
275 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
275 * |
276 * |
276 * @param string $comment_author_IP The comment author's IP address. |
277 * @param string $comment_author_IP The comment author's IP address, or an empty string if it's not available. |
277 * @param int $comment_ID The comment ID. |
278 * @param string $comment_ID The comment ID as a numeric string. |
278 * @param WP_Comment $comment The comment object. |
279 * @param WP_Comment $comment The comment object. |
279 */ |
280 */ |
280 return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase |
281 return apply_filters( 'get_comment_author_IP', $comment->comment_author_IP, $comment->comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase |
281 } |
282 } |
282 |
283 |
318 * Filters the comment author's URL. |
319 * Filters the comment author's URL. |
319 * |
320 * |
320 * @since 1.5.0 |
321 * @since 1.5.0 |
321 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
322 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
322 * |
323 * |
323 * @param string $url The comment author's URL. |
324 * @param string $url The comment author's URL, or an empty string. |
324 * @param int $comment_ID The comment ID. |
325 * @param string|int $comment_ID The comment ID as a numeric string, or 0 if not found. |
325 * @param WP_Comment $comment The comment object. |
326 * @param WP_Comment|null $comment The comment object, or null if not found. |
326 */ |
327 */ |
327 return apply_filters( 'get_comment_author_url', $url, $id, $comment ); |
328 return apply_filters( 'get_comment_author_url', $url, $id, $comment ); |
328 } |
329 } |
329 |
330 |
330 /** |
331 /** |
420 * Generates semantic classes for each comment element. |
421 * Generates semantic classes for each comment element. |
421 * |
422 * |
422 * @since 2.7.0 |
423 * @since 2.7.0 |
423 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. |
424 * @since 4.4.0 Added the ability for `$comment` to also accept a WP_Comment object. |
424 * |
425 * |
425 * @param string|string[] $class Optional. One or more classes to add to the class list. |
426 * @param string|string[] $css_class Optional. One or more classes to add to the class list. |
426 * Default empty. |
427 * Default empty. |
427 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. |
428 * @param int|WP_Comment $comment Comment ID or WP_Comment object. Default current comment. |
428 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
429 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
429 * @param bool $echo Optional. Whether to echo or return the output. |
430 * @param bool $display Optional. Whether to print or return the output. |
430 * Default true. |
431 * Default true. |
431 * @return void|string Void if `$echo` argument is true, comment classes if `$echo` is false. |
432 * @return void|string Void if `$display` argument is true, comment classes if `$display` is false. |
432 */ |
433 */ |
433 function comment_class( $class = '', $comment = null, $post_id = null, $echo = true ) { |
434 function comment_class( $css_class = '', $comment = null, $post_id = null, $display = true ) { |
434 // Separates classes with a single space, collates classes for comment DIV. |
435 // Separates classes with a single space, collates classes for comment DIV. |
435 $class = 'class="' . implode( ' ', get_comment_class( $class, $comment, $post_id ) ) . '"'; |
436 $css_class = 'class="' . implode( ' ', get_comment_class( $css_class, $comment, $post_id ) ) . '"'; |
436 |
437 |
437 if ( $echo ) { |
438 if ( $display ) { |
438 echo $class; |
439 echo $css_class; |
439 } else { |
440 } else { |
440 return $class; |
441 return $css_class; |
441 } |
442 } |
442 } |
443 } |
443 |
444 |
444 /** |
445 /** |
445 * Returns the classes for the comment div as an array. |
446 * Returns the classes for the comment div as an array. |
449 * |
450 * |
450 * @global int $comment_alt |
451 * @global int $comment_alt |
451 * @global int $comment_depth |
452 * @global int $comment_depth |
452 * @global int $comment_thread_alt |
453 * @global int $comment_thread_alt |
453 * |
454 * |
454 * @param string|string[] $class Optional. One or more classes to add to the class list. Default empty. |
455 * @param string|string[] $css_class Optional. One or more classes to add to the class list. Default empty. |
455 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. |
456 * @param int|WP_Comment $comment_id Comment ID or WP_Comment object. Default current comment. |
456 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
457 * @param int|WP_Post $post_id Post ID or WP_Post object. Default current post. |
457 * @return string[] An array of classes. |
458 * @return string[] An array of classes. |
458 */ |
459 */ |
459 function get_comment_class( $class = '', $comment_id = null, $post_id = null ) { |
460 function get_comment_class( $css_class = '', $comment_id = null, $post_id = null ) { |
460 global $comment_alt, $comment_depth, $comment_thread_alt; |
461 global $comment_alt, $comment_depth, $comment_thread_alt; |
461 |
462 |
462 $classes = array(); |
463 $classes = array(); |
463 |
464 |
464 $comment = get_comment( $comment_id ); |
465 $comment = get_comment( $comment_id ); |
513 $comment_thread_alt++; |
514 $comment_thread_alt++; |
514 } |
515 } |
515 |
516 |
516 $classes[] = "depth-$comment_depth"; |
517 $classes[] = "depth-$comment_depth"; |
517 |
518 |
518 if ( ! empty( $class ) ) { |
519 if ( ! empty( $css_class ) ) { |
519 if ( ! is_array( $class ) ) { |
520 if ( ! is_array( $css_class ) ) { |
520 $class = preg_split( '#\s+#', $class ); |
521 $css_class = preg_split( '#\s+#', $css_class ); |
521 } |
522 } |
522 $classes = array_merge( $classes, $class ); |
523 $classes = array_merge( $classes, $css_class ); |
523 } |
524 } |
524 |
525 |
525 $classes = array_map( 'esc_attr', $classes ); |
526 $classes = array_map( 'esc_attr', $classes ); |
526 |
527 |
527 /** |
528 /** |
528 * Filters the returned CSS classes for the current comment. |
529 * Filters the returned CSS classes for the current comment. |
529 * |
530 * |
530 * @since 2.7.0 |
531 * @since 2.7.0 |
531 * |
532 * |
532 * @param string[] $classes An array of comment classes. |
533 * @param string[] $classes An array of comment classes. |
533 * @param string[] $class An array of additional classes added to the list. |
534 * @param string[] $css_class An array of additional classes added to the list. |
534 * @param int $comment_id The comment ID. |
535 * @param string $comment_id The comment ID as a numeric string. |
535 * @param WP_Comment $comment The comment object. |
536 * @param WP_Comment $comment The comment object. |
536 * @param int|WP_Post $post_id The post ID or WP_Post object. |
537 * @param int|WP_Post $post_id The post ID or WP_Post object. |
537 */ |
538 */ |
538 return apply_filters( 'comment_class', $classes, $class, $comment->comment_ID, $comment, $post_id ); |
539 return apply_filters( 'comment_class', $classes, $css_class, $comment->comment_ID, $comment, $post_id ); |
539 } |
540 } |
540 |
541 |
541 /** |
542 /** |
542 * Retrieves the comment date of the current comment. |
543 * Retrieves the comment date of the current comment. |
543 * |
544 * |
622 * |
623 * |
623 * @since 1.5.0 |
624 * @since 1.5.0 |
624 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
625 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
625 * |
626 * |
626 * @param string $excerpt The comment excerpt text. |
627 * @param string $excerpt The comment excerpt text. |
627 * @param int $comment_ID The comment ID. |
628 * @param string $comment_ID The comment ID as a numeric string. |
628 * @param WP_Comment $comment The comment object. |
629 * @param WP_Comment $comment The comment object. |
629 */ |
630 */ |
630 return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); |
631 return apply_filters( 'get_comment_excerpt', $excerpt, $comment->comment_ID, $comment ); |
631 } |
632 } |
632 |
633 |
648 * |
649 * |
649 * @since 1.2.0 |
650 * @since 1.2.0 |
650 * @since 4.1.0 The `$comment_ID` parameter was added. |
651 * @since 4.1.0 The `$comment_ID` parameter was added. |
651 * |
652 * |
652 * @param string $comment_excerpt The comment excerpt text. |
653 * @param string $comment_excerpt The comment excerpt text. |
653 * @param int $comment_ID The comment ID. |
654 * @param string $comment_ID The comment ID as a numeric string. |
654 */ |
655 */ |
655 echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); |
656 echo apply_filters( 'comment_excerpt', $comment_excerpt, $comment->comment_ID ); |
656 } |
657 } |
657 |
658 |
658 /** |
659 /** |
659 * Retrieves the comment ID of the current comment. |
660 * Retrieves the comment ID of the current comment. |
660 * |
661 * |
661 * @since 1.5.0 |
662 * @since 1.5.0 |
662 * |
663 * |
663 * @return int The comment ID. |
664 * @return string The comment ID as a numeric string. |
664 */ |
665 */ |
665 function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
666 function get_comment_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid |
666 $comment = get_comment(); |
667 $comment = get_comment(); |
|
668 $comment_ID = ! empty( $comment->comment_ID ) ? $comment->comment_ID : '0'; |
667 |
669 |
668 /** |
670 /** |
669 * Filters the returned comment ID. |
671 * Filters the returned comment ID. |
670 * |
672 * |
671 * @since 1.5.0 |
673 * @since 1.5.0 |
672 * @since 4.1.0 The `$comment_ID` parameter was added. |
674 * @since 4.1.0 The `$comment` parameter was added. |
673 * |
675 * |
674 * @param int $comment_ID The current comment ID. |
676 * @param string $comment_ID The current comment ID as a numeric string. |
675 * @param WP_Comment $comment The comment object. |
677 * @param WP_Comment $comment The comment object. |
676 */ |
678 */ |
677 return apply_filters( 'get_comment_ID', $comment->comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase |
679 return apply_filters( 'get_comment_ID', $comment_ID, $comment ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase |
678 } |
680 } |
679 |
681 |
680 /** |
682 /** |
681 * Displays the comment ID of the current comment. |
683 * Displays the comment ID of the current comment. |
682 * |
684 * |
1095 * |
1097 * |
1096 * @since 1.5.0 |
1098 * @since 1.5.0 |
1097 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
1099 * @since 4.1.0 The `$comment_ID` and `$comment` parameters were added. |
1098 * |
1100 * |
1099 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. |
1101 * @param string $comment_type The type of comment, such as 'comment', 'pingback', or 'trackback'. |
1100 * @param int $comment_ID The comment ID. |
1102 * @param string $comment_ID The comment ID as a numeric string. |
1101 * @param WP_Comment $comment The comment object. |
1103 * @param WP_Comment $comment The comment object. |
1102 */ |
1104 */ |
1103 return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
1105 return apply_filters( 'get_comment_type', $comment->comment_type, $comment->comment_ID, $comment ); |
1104 } |
1106 } |
1105 |
1107 |
1734 $data_attributes = array( |
1736 $data_attributes = array( |
1735 'commentid' => $comment->comment_ID, |
1737 'commentid' => $comment->comment_ID, |
1736 'postid' => $post->ID, |
1738 'postid' => $post->ID, |
1737 'belowelement' => $args['add_below'] . '-' . $comment->comment_ID, |
1739 'belowelement' => $args['add_below'] . '-' . $comment->comment_ID, |
1738 'respondelement' => $args['respond_id'], |
1740 'respondelement' => $args['respond_id'], |
1739 'replyto' => sprintf( $args['reply_to_text'], $comment->comment_author ), |
1741 'replyto' => sprintf( $args['reply_to_text'], get_comment_author( $comment ) ), |
1740 ); |
1742 ); |
1741 |
1743 |
1742 $data_attribute_string = ''; |
1744 $data_attribute_string = ''; |
1743 |
1745 |
1744 foreach ( $data_attributes as $name => $value ) { |
1746 foreach ( $data_attributes as $name => $value ) { |
2348 $args = wp_parse_args( $args ); |
2350 $args = wp_parse_args( $args ); |
2349 if ( ! isset( $args['format'] ) ) { |
2351 if ( ! isset( $args['format'] ) ) { |
2350 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
2352 $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml'; |
2351 } |
2353 } |
2352 |
2354 |
2353 $req = get_option( 'require_name_email' ); |
2355 $req = get_option( 'require_name_email' ); |
2354 $html_req = ( $req ? " required='required'" : '' ); |
2356 $html5 = 'html5' === $args['format']; |
2355 $html5 = 'html5' === $args['format']; |
2357 |
|
2358 // Define attributes in HTML5 or XHTML syntax. |
|
2359 $required_attribute = ( $html5 ? ' required' : ' required="required"' ); |
|
2360 $checked_attribute = ( $html5 ? ' checked' : ' checked="checked"' ); |
|
2361 |
|
2362 // Identify required fields visually. |
|
2363 $required_indicator = ' <span class="required" aria-hidden="true">*</span>'; |
2356 |
2364 |
2357 $fields = array( |
2365 $fields = array( |
2358 'author' => sprintf( |
2366 'author' => sprintf( |
2359 '<p class="comment-form-author">%s %s</p>', |
2367 '<p class="comment-form-author">%s %s</p>', |
2360 sprintf( |
2368 sprintf( |
2361 '<label for="author">%s%s</label>', |
2369 '<label for="author">%s%s</label>', |
2362 __( 'Name' ), |
2370 __( 'Name' ), |
2363 ( $req ? ' <span class="required">*</span>' : '' ) |
2371 ( $req ? $required_indicator : '' ) |
2364 ), |
2372 ), |
2365 sprintf( |
2373 sprintf( |
2366 '<input id="author" name="author" type="text" value="%s" size="30" maxlength="245"%s />', |
2374 '<input id="author" name="author" type="text" value="%s" size="30" maxlength="245"%s />', |
2367 esc_attr( $commenter['comment_author'] ), |
2375 esc_attr( $commenter['comment_author'] ), |
2368 $html_req |
2376 ( $req ? $required_attribute : '' ) |
2369 ) |
2377 ) |
2370 ), |
2378 ), |
2371 'email' => sprintf( |
2379 'email' => sprintf( |
2372 '<p class="comment-form-email">%s %s</p>', |
2380 '<p class="comment-form-email">%s %s</p>', |
2373 sprintf( |
2381 sprintf( |
2374 '<label for="email">%s%s</label>', |
2382 '<label for="email">%s%s</label>', |
2375 __( 'Email' ), |
2383 __( 'Email' ), |
2376 ( $req ? ' <span class="required">*</span>' : '' ) |
2384 ( $req ? $required_indicator : '' ) |
2377 ), |
2385 ), |
2378 sprintf( |
2386 sprintf( |
2379 '<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes"%s />', |
2387 '<input id="email" name="email" %s value="%s" size="30" maxlength="100" aria-describedby="email-notes"%s />', |
2380 ( $html5 ? 'type="email"' : 'type="text"' ), |
2388 ( $html5 ? 'type="email"' : 'type="text"' ), |
2381 esc_attr( $commenter['comment_author_email'] ), |
2389 esc_attr( $commenter['comment_author_email'] ), |
2382 $html_req |
2390 ( $req ? $required_attribute : '' ) |
2383 ) |
2391 ) |
2384 ), |
2392 ), |
2385 'url' => sprintf( |
2393 'url' => sprintf( |
2386 '<p class="comment-form-url">%s %s</p>', |
2394 '<p class="comment-form-url">%s %s</p>', |
2387 sprintf( |
2395 sprintf( |
2395 ) |
2403 ) |
2396 ), |
2404 ), |
2397 ); |
2405 ); |
2398 |
2406 |
2399 if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
2407 if ( has_action( 'set_comment_cookies', 'wp_set_comment_cookies' ) && get_option( 'show_comments_cookies_opt_in' ) ) { |
2400 $consent = empty( $commenter['comment_author_email'] ) ? '' : ' checked="checked"'; |
2408 $consent = empty( $commenter['comment_author_email'] ) ? '' : $checked_attribute; |
2401 |
2409 |
2402 $fields['cookies'] = sprintf( |
2410 $fields['cookies'] = sprintf( |
2403 '<p class="comment-form-cookies-consent">%s %s</p>', |
2411 '<p class="comment-form-cookies-consent">%s %s</p>', |
2404 sprintf( |
2412 sprintf( |
2405 '<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"%s />', |
2413 '<input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"%s />', |
2435 $defaults = array( |
2443 $defaults = array( |
2436 'fields' => $fields, |
2444 'fields' => $fields, |
2437 'comment_field' => sprintf( |
2445 'comment_field' => sprintf( |
2438 '<p class="comment-form-comment">%s %s</p>', |
2446 '<p class="comment-form-comment">%s %s</p>', |
2439 sprintf( |
2447 sprintf( |
2440 '<label for="comment">%s</label>', |
2448 '<label for="comment">%s%s</label>', |
2441 _x( 'Comment', 'noun' ) |
2449 _x( 'Comment', 'noun' ), |
|
2450 $required_indicator |
2442 ), |
2451 ), |
2443 '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" required="required"></textarea>' |
2452 '<textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525"' . $required_attribute . '></textarea>' |
2444 ), |
2453 ), |
2445 'must_log_in' => sprintf( |
2454 'must_log_in' => sprintf( |
2446 '<p class="must-log-in">%s</p>', |
2455 '<p class="must-log-in">%s</p>', |
2447 sprintf( |
2456 sprintf( |
2448 /* translators: %s: Login URL. */ |
2457 /* translators: %s: Login URL. */ |
2450 /** This filter is documented in wp-includes/link-template.php */ |
2459 /** This filter is documented in wp-includes/link-template.php */ |
2451 wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2460 wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2452 ) |
2461 ) |
2453 ), |
2462 ), |
2454 'logged_in_as' => sprintf( |
2463 'logged_in_as' => sprintf( |
2455 '<p class="logged-in-as">%s</p>', |
2464 '<p class="logged-in-as">%s%s</p>', |
2456 sprintf( |
2465 sprintf( |
2457 /* translators: 1: Edit user link, 2: Accessibility text, 3: User name, 4: Logout URL. */ |
2466 /* translators: 1: Edit user link, 2: Accessibility text, 3: User name, 4: Logout URL. */ |
2458 __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
2467 __( '<a href="%1$s" aria-label="%2$s">Logged in as %3$s</a>. <a href="%4$s">Log out?</a>' ), |
2459 get_edit_user_link(), |
2468 get_edit_user_link(), |
2460 /* translators: %s: User name. */ |
2469 /* translators: %s: User name. */ |
2461 esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
2470 esc_attr( sprintf( __( 'Logged in as %s. Edit your profile.' ), $user_identity ) ), |
2462 $user_identity, |
2471 $user_identity, |
2463 /** This filter is documented in wp-includes/link-template.php */ |
2472 /** This filter is documented in wp-includes/link-template.php */ |
2464 wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2473 wp_logout_url( apply_filters( 'the_permalink', get_permalink( $post_id ), $post_id ) ) |
2465 ) |
2474 ), |
|
2475 $required_text |
2466 ), |
2476 ), |
2467 'comment_notes_before' => sprintf( |
2477 'comment_notes_before' => sprintf( |
2468 '<p class="comment-notes">%s%s</p>', |
2478 '<p class="comment-notes">%s%s</p>', |
2469 sprintf( |
2479 sprintf( |
2470 '<span id="email-notes">%s</span>', |
2480 '<span id="email-notes">%s</span>', |
2471 __( 'Your email address will not be published.' ) |
2481 __( 'Your email address will not be published.' ) |
2472 ), |
2482 ), |
2473 ( $req ? $required_text : '' ) |
2483 $required_text |
2474 ), |
2484 ), |
2475 'comment_notes_after' => '', |
2485 'comment_notes_after' => '', |
2476 'action' => site_url( '/wp-comments-post.php' ), |
2486 'action' => site_url( '/wp-comments-post.php' ), |
2477 'id_form' => 'commentform', |
2487 'id_form' => 'commentform', |
2478 'id_submit' => 'submit', |
2488 'id_submit' => 'submit', |
2528 <?php |
2538 <?php |
2529 echo $args['title_reply_before']; |
2539 echo $args['title_reply_before']; |
2530 |
2540 |
2531 comment_form_title( $args['title_reply'], $args['title_reply_to'] ); |
2541 comment_form_title( $args['title_reply'], $args['title_reply_to'] ); |
2532 |
2542 |
2533 echo $args['cancel_reply_before']; |
2543 if ( get_option( 'thread_comments' ) ) { |
2534 |
2544 echo $args['cancel_reply_before']; |
2535 cancel_comment_reply_link( $args['cancel_reply_link'] ); |
2545 |
2536 |
2546 cancel_comment_reply_link( $args['cancel_reply_link'] ); |
2537 echo $args['cancel_reply_after']; |
2547 |
|
2548 echo $args['cancel_reply_after']; |
|
2549 } |
2538 |
2550 |
2539 echo $args['title_reply_after']; |
2551 echo $args['title_reply_after']; |
2540 |
2552 |
2541 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) : |
2553 if ( get_option( 'comment_registration' ) && ! is_user_logged_in() ) : |
2542 |
2554 |
2644 } |
2656 } |
2645 |
2657 |
2646 /** |
2658 /** |
2647 * Filters a comment form field for display. |
2659 * Filters a comment form field for display. |
2648 * |
2660 * |
2649 * The dynamic portion of the filter hook, `$name`, refers to the name |
2661 * The dynamic portion of the hook name, `$name`, refers to the name |
2650 * of the comment form field. Such as 'author', 'email', or 'url'. |
2662 * of the comment form field. |
|
2663 * |
|
2664 * Possible hook names include: |
|
2665 * |
|
2666 * - `comment_form_field_comment` |
|
2667 * - `comment_form_field_author` |
|
2668 * - `comment_form_field_email` |
|
2669 * - `comment_form_field_url` |
|
2670 * - `comment_form_field_cookies` |
2651 * |
2671 * |
2652 * @since 3.0.0 |
2672 * @since 3.0.0 |
2653 * |
2673 * |
2654 * @param string $field The HTML-formatted output of the comment form field. |
2674 * @param string $field The HTML-formatted output of the comment form field. |
2655 */ |
2675 */ |