JS Filters
lzb.registerBlockType.args
Filters block arguments before they are passed to WordPress registerBlockType() function. This allows you to modify block registration data such as supports, attributes, context, and other block configuration options.
Attributes
| Name | Type | Description |
|---|---|---|
blockArgs | Object | Block arguments object for registerBlockType() |
blockSlug | String | Block slug identifier |
blockData | Object | Original LazyBlock configuration data |
Usage
import { addFilter } from '@wordpress/hooks';
function modifyBlockArgs( blockArgs, blockSlug, blockData ) {
// Add custom supports to all blocks
blockArgs.supports = {
...blockArgs.supports,
anchor: true,
className: false,
};
// Modify specific block
if ( blockSlug === 'lazyblock/my-custom-block' ) {
blockArgs.supports.color = {
background: true,
text: true,
};
// Add custom attributes
blockArgs.attributes = {
...blockArgs.attributes,
customAttribute: {
type: 'string',
default: 'custom-value',
},
};
}
return blockArgs;
}
addFilter(
'lzb.registerBlockType.args',
'my-theme/modify-block-args',
modifyBlockArgs
);Previous Articlelzb.editor.control.updateValueNext Articlelzb.components.PreviewServerCallback.onBeforeChange