Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function (wp) {
- //WordPress APIs
- //Render function
- var el = wp.element.createElement;
- //Translations
- var __ = wp.i18n.__;
- //Text input control
- var TextControl = wp.blocks.InspectorControls.TextControl;
- //Create block
- wp.blocks.registerBlockType('shelob9/metatest2', {
- title: __('Meta 2 and Markup', 'metatest'),
- category: 'common',
- edit: function (props) {
- //Make sure "fake_content" and "content" are in sync
- if( props.attributes.fake_content !== props.attributes.content ){
- props.setAttributes({fake_content: props.attributes.content });
- }
- //Edit interface
- return el(
- 'div',
- {
- },
- [
- el(
- 'p',
- {
- className: props.className
- },
- props.attributes.content
- ),
- el(
- TextControl,
- {
- label: __('Content', 'metatest'),
- value: props.attributes.fake_content,
- onChange: function (value) {
- //Update both attributes
- props.setAttributes({
- fake_content: value,
- content: value
- });
- }
- },
- )
- ]
- )
- },
- save: function (props) {
- return el(
- 'p',
- {className: props.className},
- //Save the non-meta attribute
- props.attributes.fake_content
- );
- }
- });
- })(
- window.wp
- );
Add Comment
Please, Sign In to add comment