Skip to content
PHP Filters

lzb/prepare_block_attribute

Filters attribute data for each control, that used when registering blocks.

Attributes

NameTypeDescription
$attribute_dataArrayattribute data
$controlArraycontrol data
$controlsArrayall available controls
$kStringcurrent control ID in an array of controls
$blockArrayblock data

Usage

PHP
function my_lzb_prepare_block_attribute( $attribute_data, $control, $controls, $k, $block ) {
  // Change default value for custom control "my-control"
  if ( $control && isset( $control['type'] ) && 'my-control' === $control['type'] ) {
    $attribute_data['default'] = 'my custom default value';
    return $attribute_data;
  }
 
  return $attribute_data;
}
 
add_filter( 'lzb/prepare_block_attribute', 'my_lzb_prepare_block_attribute', 10, 5 );

Was this article helpful?