块.js
(function (blocks, editor, components, i18n, element) {
var el = element.createElement;
blocks.registerBlockType('block-category/block-name', {
...
edit: function(props) {
el(editor.InnerBlocks, {
allowedBlocks: ['core/heading'],
template: [['core/heading', {'placeholder':'Placeholder text'}]],
})
},
save: function(props) {
return el(editor.InnerBlocks.Content);
}
});
})(
window.wp.blocks,
window.wp.editor,
window.wp.components,
window.wp.i18n,
window.wp.element
);
块.php
add_action('init', function() {
wp_register_script(
'block_script',
plugins_url('block.js', __FILE__),
array('wp-blocks', 'wp-components', 'wp-element', 'wp-i18n', 'wp-editor'),
filemtime(plugin_dir_path(__FILE__) . 'block.js'),
true
);
'editor_script' => 'block_script',
register_block_type('block-category/block-name', array(
'render_callback' => function($attributes, $content) {
return $content;
}
));
});