PluginProbe
Gutenberg / 14.5.2
Gutenberg v14.5.2
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/block-library/blocks/post-author.php +11 -5 12.6.0 → 14.5.2 View file →
@@ -14,12 +14,13 @@
14 14 * @return string Returns the rendered author block.
15 15 */
16 16 function gutenberg_render_block_core_post_author( $attributes, $content, $block ) {
17 17 if ( ! isset( $block->context['postId'] ) ) {
18 - return '';
18 + $author_id = get_query_var( 'author' );
19 + } else {
20 + $author_id = get_post_field( 'post_author', $block->context['postId'] );
19 21 }
20 22
21 - $author_id = get_post_field( 'post_author', $block->context['postId'] );
22 23 if ( empty( $author_id ) ) {
23 24 return '';
24 25 }
25 26
@@ -27,11 +28,16 @@
27 28 $author_id,
28 29 $attributes['avatarSize']
29 30 ) : null;
30 31
32 + $link = get_author_posts_url( $author_id );
33 + $author_name = get_the_author_meta( 'display_name', $author_id );
34 + if ( ! empty( $attributes['isLink'] && ! empty( $attributes['linkTarget'] ) ) ) {
35 + $author_name = sprintf( '<a href="%1s" target="%2s">%2s</a>', esc_url( $link ), esc_attr( $attributes['linkTarget'] ), $author_name );
36 + }
37 +
31 38 $byline = ! empty( $attributes['byline'] ) ? $attributes['byline'] : false;
32 39 $classes = array_merge(
33 - isset( $attributes['className'] ) ? array( $attributes['className'] ) : array(),
34 40 isset( $attributes['itemsJustification'] ) ? array( 'items-justified-' . $attributes['itemsJustification'] ) : array(),
35 41 isset( $attributes['textAlign'] ) ? array( 'has-text-align-' . $attributes['textAlign'] ) : array()
36 42 );
37 43
@@ -39,10 +45,10 @@
39 45
40 46 return sprintf( '<div %1$s>', $wrapper_attributes ) .
41 47 ( ! empty( $attributes['showAvatar'] ) ? '<div class="wp-block-post-author__avatar">' . $avatar . '</div>' : '' ) .
42 48 '<div class="wp-block-post-author__content">' .
43 - ( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . esc_html( $byline ) . '</p>' : '' ) .
44 - '<p class="wp-block-post-author__name">' . get_the_author_meta( 'display_name', $author_id ) . '</p>' .
49 + ( ! empty( $byline ) ? '<p class="wp-block-post-author__byline">' . wp_kses_post( $byline ) . '</p>' : '' ) .
50 + '<p class="wp-block-post-author__name">' . $author_name . '</p>' .
45 51 ( ! empty( $attributes['showBio'] ) ? '<p class="wp-block-post-author__bio">' . get_the_author_meta( 'user_description', $author_id ) . '</p>' : '' ) .
46 52 '</div>' .
47 53 '</div>';
48 54 }