我希望能够更改core/heading
阻止此处显示的标签,最好的方法是什么?
How change a core block label
1 个回复
最合适的回答,由SO网友:Sally CJ 整理而成
这是块标题,您可以使用blocks.registerBlockType
filter in the block editor 更改块标题和其他设置。
例如,这会将标题更改为;我的标题:
function changeHeadingBlockTitle( settings, name ) {
if ( name !== \'core/heading\' ) {
return settings;
}
return lodash.assign( {}, settings, {
title: \'My Heading\',
} );
}
wp.hooks.addFilter(
\'blocks.registerBlockType\',
\'my-plugin/foo\',
changeHeadingBlockTitle
);