[wp-trac] [WordPress Trac] #61422: registerBlockVariation not holding the blockName param
WordPress Trac
noreply at wordpress.org
Wed Jun 19 08:55:38 UTC 2024
#61422: registerBlockVariation not holding the blockName param
-----------------------------+------------------------------
Reporter: heymehedi | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses: javascript
-----------------------------+------------------------------
Comment (by heymehedi):
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;
}
console.log(name);
// My custom code goes here
return settings;
};
addFilter(
'blocks.registerBlockType',
'gutenberg-button-block-variation/extend-button-block',
addButtonBlockCustomAttributes
);
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61422#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list