44 if ( empty( $author_id ) ) { |
44 if ( empty( $author_id ) ) { |
45 return ''; |
45 return ''; |
46 } |
46 } |
47 |
47 |
48 $author_name = get_the_author_meta( 'display_name', $author_id ); |
48 $author_name = get_the_author_meta( 'display_name', $author_id ); |
49 // translators: %s is the Author name. |
49 // translators: %s: Author name. |
50 $alt = sprintf( __( '%s Avatar' ), $author_name ); |
50 $alt = sprintf( __( '%s Avatar' ), $author_name ); |
51 $avatar_block = get_avatar( |
51 $avatar_block = get_avatar( |
52 $author_id, |
52 $author_id, |
53 $size, |
53 $size, |
54 '', |
54 '', |
62 $label = ''; |
62 $label = ''; |
63 if ( '_blank' === $attributes['linkTarget'] ) { |
63 if ( '_blank' === $attributes['linkTarget'] ) { |
64 // translators: %s is the Author name. |
64 // translators: %s is the Author name. |
65 $label = 'aria-label="' . esc_attr( sprintf( __( '(%s author archive, opens in a new tab)' ), $author_name ) ) . '"'; |
65 $label = 'aria-label="' . esc_attr( sprintf( __( '(%s author archive, opens in a new tab)' ), $author_name ) ) . '"'; |
66 } |
66 } |
67 // translators: %1$s: Author archive link. %2$s: Link target. %3$s Aria label. %4$s Avatar image. |
67 // translators: 1: Author archive link. 2: Link target. %3$s Aria label. %4$s Avatar image. |
68 $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( get_author_posts_url( $author_id ) ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); |
68 $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( get_author_posts_url( $author_id ) ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); |
69 } |
69 } |
70 return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block ); |
70 return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block ); |
71 } |
71 } |
72 $comment = get_comment( $block->context['commentId'] ); |
72 $comment = get_comment( $block->context['commentId'] ); |
73 if ( ! $comment ) { |
73 if ( ! $comment ) { |
74 return ''; |
74 return ''; |
75 } |
75 } |
76 /* translators: %s is the Comment Author name */ |
76 /* translators: %s: Author name. */ |
77 $alt = sprintf( __( '%s Avatar' ), $comment->comment_author ); |
77 $alt = sprintf( __( '%s Avatar' ), $comment->comment_author ); |
78 $avatar_block = get_avatar( |
78 $avatar_block = get_avatar( |
79 $comment, |
79 $comment, |
80 $size, |
80 $size, |
81 '', |
81 '', |
86 ) |
86 ) |
87 ); |
87 ); |
88 if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) { |
88 if ( isset( $attributes['isLink'] ) && $attributes['isLink'] && isset( $comment->comment_author_url ) && '' !== $comment->comment_author_url ) { |
89 $label = ''; |
89 $label = ''; |
90 if ( '_blank' === $attributes['linkTarget'] ) { |
90 if ( '_blank' === $attributes['linkTarget'] ) { |
91 // translators: %s is the Comment Author name. |
91 // translators: %s: Comment author name. |
92 $label = 'aria-label="' . esc_attr( sprintf( __( '(%s website link, opens in a new tab)' ), $comment->comment_author ) ) . '"'; |
92 $label = 'aria-label="' . esc_attr( sprintf( __( '(%s website link, opens in a new tab)' ), $comment->comment_author ) ) . '"'; |
93 } |
93 } |
94 // translators: %1$s: Comment Author website link. %2$s: Link target. %3$s Aria label. %4$s Avatar image. |
|
95 $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); |
94 $avatar_block = sprintf( '<a href="%1$s" target="%2$s" %3$s class="wp-block-avatar__link">%4$s</a>', esc_url( $comment->comment_author_url ), esc_attr( $attributes['linkTarget'] ), $label, $avatar_block ); |
96 } |
95 } |
97 return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block ); |
96 return sprintf( '<div %1s>%2s</div>', $wrapper_attributes, $avatar_block ); |
98 } |
97 } |
99 |
98 |