Skip to content

Commit

Permalink
Widget Group: Make save() markup the same as render_callback mark…
Browse files Browse the repository at this point in the history
…up (#38510)
  • Loading branch information
noisysocks authored Mar 8, 2022
1 parent 58d74b6 commit 5f140a6
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
32 changes: 32 additions & 0 deletions packages/widgets/src/blocks/widget-group/deprecated.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* WordPress dependencies
*/
import { InnerBlocks, RichText } from '@wordpress/block-editor';

const v1 = {
attributes: {
title: {
type: 'string',
},
},
supports: {
html: false,
inserter: true,
customClassName: true,
reusable: false,
},
save( { attributes } ) {
return (
<>
<RichText.Content
tagName="h2"
className="widget-title"
value={ attributes.title }
/>
<InnerBlocks.Content />
</>
);
},
};

export default [ v1 ];
3 changes: 3 additions & 0 deletions packages/widgets/src/blocks/widget-group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { group as icon } from '@wordpress/icons';
import metadata from './block.json';
import edit from './edit';
import save from './save';
import deprecated from './deprecated';

const { name } = metadata;
export { metadata, name };

Expand Down Expand Up @@ -73,4 +75,5 @@ export const settings = {
},
],
},
deprecated,
};
4 changes: 3 additions & 1 deletion packages/widgets/src/blocks/widget-group/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default function save( { attributes } ) {
className="widget-title"
value={ attributes.title }
/>
<InnerBlocks.Content />
<div className="wp-widget-group__inner-blocks">
<InnerBlocks.Content />
</div>
</>
);
}

0 comments on commit 5f140a6

Please sign in to comment.