Skip to content

Instantly share code, notes, and snippets.

@jorgefilipecosta
Created April 17, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgefilipecosta/ee7969d72e13e9e8e3ab58efdd1fd03b to your computer and use it in GitHub Desktop.
Save jorgefilipecosta/ee7969d72e13e9e8e3ab58efdd1fd03b to your computer and use it in GitHub Desktop.
( function() {
const { registerBlockType } = wp.blocks;
const { createElement: el } = wp.element;
const { InnerBlocks } = wp.editor;
const { __ } = wp.i18n;
const divProps = { className: 'product', style: { outline: '1px solid gray', padding: 5 } };
const template = [
[ 'core/image' ],
[ 'core/video' ],
[ 'core/cover' ],
];
const save = function() {
return el( 'div', divProps,
el( InnerBlocks.Content )
);
};
registerBlockType( 'test/allowed-blocks-set', {
title: 'Allowed Blocks Set',
icon: 'carrot',
category: 'common',
edit() {
return el( 'div', divProps,
el(
InnerBlocks,
{
template,
allowedBlocks: [
'core/button',
'core/gallery',
'core/list',
'core/media-text',
'core/quote',
],
}
)
);
},
save,
} );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment