5 * @package WordPress |
5 * @package WordPress |
6 */ |
6 */ |
7 |
7 |
8 /** |
8 /** |
9 * Renders the `core/comment-author-name` block on the server. |
9 * Renders the `core/comment-author-name` block on the server. |
|
10 * |
|
11 * @since 6.0.0 |
10 * |
12 * |
11 * @param array $attributes Block attributes. |
13 * @param array $attributes Block attributes. |
12 * @param string $content Block default content. |
14 * @param string $content Block default content. |
13 * @param WP_Block $block Block instance. |
15 * @param WP_Block $block Block instance. |
14 * @return string Return the post comment's author. |
16 * @return string Return the post comment's author. |
23 $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; |
25 $show_pending_links = isset( $commenter['comment_author'] ) && $commenter['comment_author']; |
24 if ( empty( $comment ) ) { |
26 if ( empty( $comment ) ) { |
25 return ''; |
27 return ''; |
26 } |
28 } |
27 |
29 |
28 $classes = ''; |
30 $classes = array(); |
29 if ( isset( $attributes['textAlign'] ) ) { |
31 if ( isset( $attributes['textAlign'] ) ) { |
30 $classes .= 'has-text-align-' . $attributes['textAlign']; |
32 $classes[] = 'has-text-align-' . $attributes['textAlign']; |
|
33 } |
|
34 if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { |
|
35 $classes[] = 'has-link-color'; |
31 } |
36 } |
32 |
37 |
33 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); |
38 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classes ) ) ); |
34 $comment_author = get_comment_author( $comment ); |
39 $comment_author = get_comment_author( $comment ); |
35 $link = get_comment_author_url( $comment ); |
40 $link = get_comment_author_url( $comment ); |
36 |
41 |
37 if ( ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) { |
42 if ( ! empty( $link ) && ! empty( $attributes['isLink'] ) && ! empty( $attributes['linkTarget'] ) ) { |
38 $comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author ); |
43 $comment_author = sprintf( '<a rel="external nofollow ugc" href="%1s" target="%2s" >%3s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $comment_author ); |
39 } |
44 } |
40 if ( '0' === $comment->comment_approved && ! $show_pending_links ) { |
45 if ( '0' === $comment->comment_approved && ! $show_pending_links ) { |
41 $comment_author = wp_kses( $comment_author, array() ); |
46 $comment_author = wp_kses( $comment_author, array() ); |
42 } |
47 } |