Skip to content
PHP Filters

lzb/get_blocks

Filters the list of all LazyBlock blocks data. This filter provides access to the complete array of block data for all registered LazyBlock blocks.

Attributes

NameTypeDescription
$blocksArrayArray containing all LazyBlock blocks data

Usage

PHP
function my_lzb_get_blocks( $blocks ) {
  // Add custom data to all blocks
  foreach ( $blocks as $key => $block ) {
    $blocks[ $key ]['custom_property'] = 'custom_value';
  }
 
  // Or filter specific blocks
  foreach ( $blocks as $key => $block ) {
    if ( $block['slug'] === 'my-block' ) {
      $blocks[ $key ]['additional_data'] = 'some_value';
    }
  }
 
  return $blocks;
}
 
add_filter( 'lzb/get_blocks', 'my_lzb_get_blocks', 10, 1 );

Was this article helpful?