Skip to content

Instantly share code, notes, and snippets.

@jorgefilipecosta
Created September 6, 2018 19:02
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/9ca39e388f6c46881809f0323f681197 to your computer and use it in GitHub Desktop.
Save jorgefilipecosta/9ca39e388f6c46881809f0323f681197 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;
var __ = wp.i18n.__;
var ALLOWED_BLOCKS = [ 'core/image' ];
var TEMPLATE = [
[ 'core/image' ],
[ 'core/image' ],
[ 'core/image' ],
];
registerBlockType( 'myplugin/test', {
title: 'Test InnerBlocks',
icon: 'cart',
category: 'common',
attributes: {
align: {
type: 'string',
default: 'wide',
},
},
supports: {
align: [ 'wide', 'full' ],
},
edit: function( props ) {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el(
InnerBlocks,
{
allowedBlocks: ALLOWED_BLOCKS,
template: TEMPLATE,
templateLock: false,
}
)
);
},
save: function() {
return el( 'div', { style: { outline: '1px solid gray', padding: 5 } },
el( InnerBlocks.Content )
);
},
} );
} )();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment