Skip to content

Instantly share code, notes, and snippets.

@avillegasn
Last active March 23, 2018 06:33
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save avillegasn/ddbe35ceb44cf393a8a92734067c2c67 to your computer and use it in GitHub Desktop.
( function( blocks, components, i18n, element ) {
var el = element.createElement;
blocks.registerBlockType(
// The name of our block. Must be a string with prefix. Example: my-plugin/my-custom-block.
'nelio/testimonial-block', {
// The title of our block.
title: i18n.__( 'Testimonial' ),
// Dashicon icon for our block.
icon: 'megaphone',
// The category of the block.
category: 'common',
// Necessary for saving block content.
attributes: {
name: {
type: 'array',
source: 'children',
selector: 'p.nelio-testimonial-name',
},
position: {
type: 'array',
source: 'children',
selector: 'p.nelio-testimonial-position',
},
testimonial: {
type: 'array',
source: 'children',
selector: 'p',
},
mediaID: {
type: 'number',
},
mediaURL: {
type: 'string',
source: 'attribute',
selector: 'img',
attribute: 'src',
},
alignment: {
type: 'string',
default: 'center',
}
},
edit: function( props ) {
...
},
save: function( props ) {
...
}
} );
} )(
window.wp.blocks,
window.wp.components,
window.wp.i18n,
window.wp.element,
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment