在函数中。我添加的php文件
add_filter( \'allowed_block_types_all\', \'func_allowed_block_types\' );
function func_allowed_block_types( $allowed_blocks ) {
return array(
\'core/embed\'
);
}
然后在我的插件中,我将这个JS添加到javascript文件中,以便只启用我想要的嵌入块(Twitter、youTube和Vimeo)
wp.domReady( function() {
const allowedEmbedBlocks = [
\'twitter\',\'youtube\', \'vimeo\'
];
wp.blocks.getBlockType( \'core/embed\' ).variations.forEach( function( blockVariation ) {
if (
allowedEmbedBlocks.indexOf( blockVariation.name ) === -1
) {
wp.blocks.unregisterBlockVariation( \'core/embed\', blockVariation.name );
}
} );
} );