equal
deleted
inserted
replaced
6 */ |
6 */ |
7 |
7 |
8 /** |
8 /** |
9 * Renders the `core/post-author-biography` block on the server. |
9 * Renders the `core/post-author-biography` block on the server. |
10 * |
10 * |
|
11 * @since 6.0.0 |
|
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 Returns the rendered post author biography block. |
16 * @return string Returns the rendered post author biography block. |
15 */ |
17 */ |
16 function render_block_core_post_author_biography( $attributes, $content, $block ) { |
18 function render_block_core_post_author_biography( $attributes, $content, $block ) { |
17 if ( ! isset( $block->context['postId'] ) ) { |
19 if ( isset( $block->context['postId'] ) ) { |
18 return ''; |
20 $author_id = get_post_field( 'post_author', $block->context['postId'] ); |
|
21 } else { |
|
22 $author_id = get_query_var( 'author' ); |
19 } |
23 } |
20 |
24 |
21 $author_id = get_post_field( 'post_author', $block->context['postId'] ); |
|
22 if ( empty( $author_id ) ) { |
25 if ( empty( $author_id ) ) { |
23 return ''; |
26 return ''; |
24 } |
27 } |
25 |
28 |
26 $author_biography = get_the_author_meta( 'description', $author_id ); |
29 $author_biography = get_the_author_meta( 'description', $author_id ); |
34 return sprintf( '<div %1$s>', $wrapper_attributes ) . $author_biography . '</div>'; |
37 return sprintf( '<div %1$s>', $wrapper_attributes ) . $author_biography . '</div>'; |
35 } |
38 } |
36 |
39 |
37 /** |
40 /** |
38 * Registers the `core/post-author-biography` block on the server. |
41 * Registers the `core/post-author-biography` block on the server. |
|
42 * |
|
43 * @since 6.0.0 |
39 */ |
44 */ |
40 function register_block_core_post_author_biography() { |
45 function register_block_core_post_author_biography() { |
41 register_block_type_from_metadata( |
46 register_block_type_from_metadata( |
42 __DIR__ . '/post-author-biography', |
47 __DIR__ . '/post-author-biography', |
43 array( |
48 array( |