Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#61422 new feature request

registerBlockVariation not holding the blockName param

Reported by: heymehedi's profile heymehedi Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Editor Keywords:
Focuses: javascript Cc:


After adding a variation of a core block like core/button or any other, It can't access the blockName of the newly created variation. I hope this is important to have.

Change History (2)

#1 @gziolo
6 weeks ago

  • Component changed from General to Editor

Could you provide the code example of the intended usage to better illustrate your use case?

#2 @heymehedi
5 weeks ago

Hi @gziolo ,

Here you go:

I have created a variation using a hook.

wp.blocks.registerBlockVariation( 'core/button', {
	title: __( 'Custom Button Block' ),
    name: 'custom-button-block',
    attributes: {
        textColor: 'vivid-red',
} );

and, then I am trying to do something if the name is 'custom-button-block'

const addButtonBlockCustomAttributes = (settings, name) => {
    if (name !== 'custom-button-block') {
        return settings;


	// My custom code goes here

    return settings;

Note: See TracTickets for help on using tickets.