Skip to content
PHP Filters

lzb/block_render/allow_wrapper

Filter for standard block wrapper <div>, which contains block classes, IDs, and attributes.

See additional info here – https://www.lazyblocks.com/docs/blocks-code/php-callback/#frontend-output-wrapper

Attributes

NameTypeDescription
$allow_wrapperBooleanallow wrapper rendering
$attributesArrayblock attributes
$contextStringrendering context [editor, frontend]

Additional Filters

NameDescription
lazyblock/BLOCK_SLUG/frontend_allow_wrapperspecific block in the frontend only
lazyblock/BLOCK_SLUG/editor_allow_wrapperspecific block in the editor only
lazyblock/BLOCK_SLUG/allow_wrapperspecific block only

Usage

PHP
function my_lzb_block_render_allow_wrapper( $allow_wrapper, $attributes, $context ) {
  // Disable block output if there is a custom attribute "my-attribute"
  if ( isset( $attributes['my-attribute'] ) && $attributes['my-attribute'] ) {
    return false;
  }
 
  return $allow_wrapper;
}
 
add_filter( 'lzb/block_render/allow_wrapper', 'my_lzb_block_render_allow_wrapper', 10, 3 );
PHP
function my_lzb_block_render_allow_wrapper( $allow_wrapper, $attributes, $context ) {
  // Disable block output for block "lazyblock/my-custom-block"
  return false;
}
 
add_filter( 'lazyblock/my-custom-block/allow_wrapper', 'my_lzb_block_render_allow_wrapper', 10, 3 );
PHP
// Disable block frontend wrapper for all blocks.
add_filter( 'lzb/block_render/frontend_allow_wrapper', '__return_false' );

Was this article helpful?