好的,我找到了一种方法browsing the source code. 我注意到帮助我的代码deprecated.js
所以这可能不会继续起作用。
这是我插件目录中的JS代码
function addAlignmentToGroups(settings, name) {
if (name !== "core/group") {
return settings;
}
return lodash.assign({}, settings, {
supports: lodash.assign( {}, settings.supports, {
align: [\'wide\', \'full\', \'left\', \'center\', \'right\']
})
});
}
wp.hooks.addFilter(
\'blocks.registerBlockType\',
\'myapp/alignments/group-block\',
addAlignmentToGroups
);
以及加载它的PHP代码:
<?php
function my_enqueue() {
wp_enqueue_script(
\'my-align-blocks\',
plugins_url(\'dist/align-blocks.js\', __FILE__),
[\'wp-blocks\']
);
}
add_action(\'enqueue_block_editor_assets\', \'my_enqueue\');