lzb/block_render/allow_wrapper
Stops Lazy Blocks adding its own outer <div> to a block whose template already opens with the element it wants.
This filter is deprecated since v4.0.0. It still runs, and WordPress logs a deprecation notice when it does. Add the wrapper attributes with useBlockProps instead.
Returning false only skips the automatic <div useBlockProps>. It has no effect at all on a template that already carries a useBlockProps attribute on one of its own tags, because Lazy Blocks adds the wrapper only when it cannot find one. Marking your own outer tag with useBlockProps does the same job without the deprecation notice, and keeps the block's classes, anchor and alignment on an element you control. The filter runs on the front end only.
Attributes
| Name | Type | Description |
|---|---|---|
$allow_wrapper | Boolean | render the wrapper, true by default |
$attributes | Array | control values, as the template saw them |
$render_location | String | always frontend |
Additional Filters
| Name | Arguments | Description |
|---|---|---|
lazyblock/BLOCK_SLUG/frontend_allow_wrapper | $allow_wrapper, $attributes | specific block in the frontend only |
lazyblock/BLOCK_SLUG/allow_wrapper | $allow_wrapper, $attributes, $render_location | specific block only |
Both variants are deprecated on the same terms as the main filter, and each logs its own notice.
Usage
function my_lzb_block_render_allow_wrapper( $allow_wrapper, $attributes, $render_location ) {
// The table block renders a <table> and cannot sit inside a div.
if ( 'lazyblock/data-table' === $attributes['lazyblock']['slug'] ) {
return false;
}
return $allow_wrapper;
}
add_filter( 'lzb/block_render/allow_wrapper', 'my_lzb_block_render_allow_wrapper', 10, 3 );// Drop the wrapper for one block on the front end.
add_filter( 'lazyblock/data-table/frontend_allow_wrapper', '__return_false' );Dropping the wrapper without marking a tag useBlockProps also drops the block's generated classes, its anchor ID and its alignment class, because those are only applied to the useBlockProps element. That is the reason the replacement exists.
See Block Wrapper for what the wrapper contains.