lzb/controls/all
Registers a control type, or changes one that already exists, which is the single place the block builder's control list comes from.
The default value is an empty array. Every built-in control adds itself here from its own class, keyed by its type slug, on lzb/init at priority 5. Nothing else builds the list, so a handler that returns something other than the array it was given removes every control from the block builder and drops every control from every block, because prepare_block_controls() silently discards a control whose type it cannot find.
Attributes
| Name | Type | Description |
|---|---|---|
$controls | Array | control definitions, keyed by control type slug |
Each entry holds these keys:
| Key | Type | Description |
|---|---|---|
name | String | type slug, the same as the array key |
icon | String | SVG markup shown in the control picker |
type | String | attribute type, one of string, number, boolean, array, object |
label | String | control name shown in the block builder |
category | String | grouping in the control picker, see lzb/controls/categories |
restrictions | Array | which settings the block builder offers for this control |
attributes | Array | defaults merged into every control of this type |
Usage
function my_lzb_controls_all( $controls ) {
// Keep the Code Editor control out of the block builder for everyone
// who cannot edit files, and move Number next to Text.
if ( ! current_user_can( 'edit_themes' ) ) {
unset( $controls['code_editor'] );
}
if ( isset( $controls['number'] ) ) {
$controls['number']['category'] = 'basic';
}
return $controls;
}
add_filter( 'lzb/controls/all', 'my_lzb_controls_all', 11 );Use priority 11 or later. The built-in controls register at the default priority 10, so a handler at 10 or below sees a list that is still being filled. Removing a type that blocks already use makes those controls vanish from the blocks as well, not only from the picker, and the attributes behind them stop being registered.
Adding a control type of your own is covered in Create Custom Control, which subclasses LazyBlocks_Control and lets the base class hook this filter for you.