Skip to content

Instantly share code, notes, and snippets.

@jorgefilipecosta
Created August 24, 2018 22: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/7dbcf8ce79c57acc6eb2c64f0088f480 to your computer and use it in GitHub Desktop.
Save jorgefilipecosta/7dbcf8ce79c57acc6eb2c64f0088f480 to your computer and use it in GitHub Desktop.
( function() {
var registerBlockType = wp.blocks.registerBlockType;
var el = wp.element.createElement;
var InnerBlocks = wp.editor.InnerBlocks;
registerBlockType( 'test/parent', {
title: 'Test Parent',
icon: 'cart',
category: 'common',
edit: function() {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el(
InnerBlocks,
{
template: [
[ 'test/child' ],
],
templateLock: false,
}
)
);
},
save: function() {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el( InnerBlocks.Content, {} )
);
},
} );
registerBlockType( 'test/child', {
title: 'Test Child',
icon: 'cart',
category: 'common',
parent: [ 'test/parent' ],
supports: {
inserter: false,
},
edit: function() {
return 'Child';
},
save: function() {
return 'Child';
},
} );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment