Skip to content

Commit

Permalink
remove explicit check for area block attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Mar 22, 2021
1 parent 3e6b951 commit 83fce5a
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ export default function TemplatePartPlaceholder( {
const { saveEntityRecord } = useDispatch( coreStore );
const onCreate = useCallback( async () => {
const title = __( 'Untitled Template Part' );
// If we have `area` set from block attributes, means an exposed
// block variation was inserted. So add this prop to the template
// part entity on creation. Afterwards remove `area` value from
// block attributes.
const record = {
title,
slug: 'template-part',
content: serialize( innerBlocks ),
// `area` is filterable on the server and defaults to `UNCATEGORIZED`
// if provided value is not allowed.
area,
};
// If we have `area` set from block attributes, means an exposed
// block variation was inserted. So add this prop to the template
// part entity on creation. Afterwards remove `area` value from
// block attributes.
if ( [ 'header', 'footer' ].includes( area ) ) record.area = area;
const templatePart = await saveEntityRecord(
'postType',
'wp_template_part',
Expand Down

0 comments on commit 83fce5a

Please sign in to comment.