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
Name | Type | Description |
---|---|---|
$blocks | Array | Array containing all LazyBlock blocks data |
Usage
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 );