Skip to content

Instantly share code, notes, and snippets.

@Shininglow
Created August 21, 2019 14:17
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 Shininglow/e11de5758501f53c8b91c88f642cedac to your computer and use it in GitHub Desktop.
Save Shininglow/e11de5758501f53c8b91c88f642cedac to your computer and use it in GitHub Desktop.
extra gutenberg block js
wp.blocks.registerBlockType('my_new-block', {
title: 'My Extra Block',
icon: 'heart',
category: 'common',
attributes: {
content: {type: 'string'}
},
edit: function(props) {
function somename(event) {
props.setAttributes({content: event.target.value})
}
return wp.element.createElement(
"div",
null,
wp.element.createElement(
"h3",
null,
"Enter your sample text"
),
wp.element.createElement("input", { type: "text", value: props.attributes.content, onChange: somename })
);
},
save: function(props) {
return null
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment