lzb/register_block_type_data
Adds a register_block_type() argument that the block builder has no field for, such as a stylesheet handle, a view script or a replacement render callback.
This is the last of the four block filters and the only one whose result reaches WordPress directly. register_block_render() builds the array, fires this filter, then calls register_block_type( $block['slug'], $data ). Lazy Blocks Pro hooks it twice, once to attach the CSS and JS handles built from a block's template folder, and once to swap in a render callback that forwards block context when the block uses Relationships.
Attributes
| Name | Type | Description |
|---|---|---|
$data | Array | arguments about to be passed to register_block_type() |
$block | Array | block data, the same array lzb/block_data returns |
$data holds these keys before any handler runs:
| Key | Type | Description |
|---|---|---|
api_version | Int | always 3 |
attributes | Array | one entry per control, built by lzb/prepare_block_attribute plus the reserved lazyblock, className, anchor, blockId and blockUniqueClass attributes |
supports | Array | the block's supports array |
render_callback | Callable | closure calling render_callback() with the render location and the block context, limited to the keys listed in uses_context |
example | Array | empty, so the inserter preview renders with defaults |
styles | Array | block style variations |
editor_script | Array | lazyblocks-editor |
editor_style | Array | lazyblocks-editor |
Usage
function my_lzb_register_block_type_data( $data, $block ) {
// Attach a theme stylesheet to one block, so it loads only on pages
// where the block is actually used.
if ( 'lazyblock/pricing-table' !== $block['slug'] ) {
return $data;
}
wp_register_style(
'my-theme-pricing-table',
get_stylesheet_directory_uri() . '/css/pricing-table.css',
array(),
'1.0.0'
);
$data['style'] = array( 'my-theme-pricing-table' );
return $data;
}
add_filter( 'lzb/register_block_type_data', 'my_lzb_register_block_type_data', 10, 2 );style, editor_style and view_script take handles that are already registered, not URLs, and Lazy Blocks Pro appends to those keys rather than replacing them, so read the existing value before overwriting one. Replacing render_callback with something that is not callable makes register_block_type() fail for that block and it never appears in the inserter. Removing attributes leaves the block unable to read any of its own control values.
This filter shapes the server side only. The array the editor registers blocks from goes through lzb/register_blocks.