Is this not how you unregister a core button style? It doesn’t seem to unregister in Sage 11. Yet I’ve registered a <TextControl
> just fine. I was also able to register block styles, too.
// editor.js
import domReady from '@wordpress/dom-ready';
import { unregisterBlockStyle } from '@wordpress/blocks';
domReady(() => {
unregisterBlockStyle('core/button', 'outline');
});
Ultimately, I was trying to register block variations. The browser console returns the array of the variations, too. (console.log(wp.blocks.getBlockVariations('core/button'));
)
I just don’t see them inside the editor.
import domReady from '@wordpress/dom-ready';
import { registerBlockVariation } from '@wordpress/blocks';
import { extendButtonBlock } from './extendButton';
domReady(() => {
console.log('Registering Custom Button Variations...');
registerBlockVariation('core/button', {
name: 'primary',
title: 'Primary Button',
description: 'A primary button style.',
attributes: { className: 'is-style-primary' },
isDefault: false,
scope: ['block', 'inserter'],
});
registerBlockVariation('core/button', {
name: 'secondary',
title: 'Secondary Button',
description: 'A secondary button style.',
attributes: { className: 'is-style-secondary' },
isDefault: false,
scope: ['block', 'inserter'],
});
console.log('Button Variations Updated!');
// Check if they exist after registering
setTimeout(() => {
console.log('Checking registered variations:');
console.log(wp.blocks.getBlockVariations('core/button'));
}, 500);
extendButtonBlock();
});
I tried flushing the cache, using a different browser, etc.