Skip to content

Commit 6fdc1f3

Browse files
authored
Post Author Name: Add to and from Post Author transformations (#41151)
* Post Author Name: Add to and from Post Author transformations * Use a single string concatenation method
1 parent 0a45d04 commit 6fdc1f3

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

packages/block-library/src/post-author-name/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
import metadata from './block.json';
55
import edit from './edit';
6+
import transforms from './transforms';
67

78
/**
89
* WordPress dependencies
@@ -14,5 +15,6 @@ export { metadata, name };
1415

1516
export const settings = {
1617
icon,
18+
transforms,
1719
edit,
1820
};

packages/block-library/src/post-author-name/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function render_block_core_post_author_name( $attributes, $content, $block ) {
3232

3333
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) );
3434

35-
return sprintf( '<div %1$s>', $wrapper_attributes ) . $author_name . '</div>';
35+
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $author_name );
3636
}
3737

3838
/**
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* WordPress dependencies
3+
*/
4+
import { createBlock } from '@wordpress/blocks';
5+
6+
const transforms = {
7+
from: [
8+
{
9+
type: 'block',
10+
blocks: [ 'core/post-author' ],
11+
transform: ( { textAlign } ) =>
12+
createBlock( 'core/post-author-name', { textAlign } ),
13+
},
14+
],
15+
to: [
16+
{
17+
type: 'block',
18+
blocks: [ 'core/post-author' ],
19+
transform: ( { textAlign } ) =>
20+
createBlock( 'core/post-author', { textAlign } ),
21+
},
22+
],
23+
};
24+
25+
export default transforms;

0 commit comments

Comments
 (0)