PHP Filters
lzb/block_render/attributes
Filters block attribute before render block output.
Attributes
| Name | Type | Description |
|---|---|---|
$attributes | Array | block attributes |
$content | String | block content |
$block | Array | block data |
$render_location | String | rendering location [editor, frontend] |
$context | Array | block context data provided by parent blocks |
Additional Filters
| Name | Description |
|---|---|
BLOCK_SLUG/frontend_attributes | specific block in the frontend only |
BLOCK_SLUG/editor_attributes | specific block in the editor only |
BLOCK_SLUG/attributes | specific block only |
Usage
function my_lzb_block_render_attributes( $attributes, $content, $block, $render_location, $context ) {
// Change value of custom attribute "my-attribute"
$attributes['my-attribute'] = 'custom attribute value';
return $attributes;
}
add_filter( 'lzb/block_render/attributes', 'my_lzb_block_render_attributes', 10, 5 );function my_lzb_block_render_attributes( $attributes, $content, $block, $render_location, $context ) {
// Change value of custom attribute "my-attribute" for block "lazyblock/my-custom-block"
$attributes['my-attribute'] = 'custom attribute value';
return $attributes;
}
add_filter( 'lazyblock/my-custom-block/attributes', 'my_lzb_block_render_attributes', 10, 5 );