Skip to content
PHP Filters

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

NameTypeDescription
$dataArrayarguments about to be passed to register_block_type()
$blockArrayblock data, the same array lzb/block_data returns

$data holds these keys before any handler runs:

KeyTypeDescription
api_versionIntalways 3
attributesArrayone entry per control, built by lzb/prepare_block_attribute plus the reserved lazyblock, className, anchor, blockId and blockUniqueClass attributes
supportsArraythe block's supports array
render_callbackCallableclosure calling render_callback() with the render location and the block context, limited to the keys listed in uses_context
exampleArrayempty, so the inserter preview renders with defaults
stylesArrayblock style variations
editor_scriptArraylazyblocks-editor
editor_styleArraylazyblocks-editor

Usage

PHP
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.

Was this article helpful?

Copyright © 2026 Lazy Blocks.