lzb/controls/categories
Adds a section to the control type picker in the block builder, which a custom control needs before it can be grouped anywhere but under an existing heading.
The default is six categories in this order.
| Slug | Label |
|---|---|
basic | Basic |
content | Content |
choice | Choice |
advanced | Advanced |
layout | Layout |
deprecated | Deprecated |
The result is localised as lazyblocksBlockBuilderData.controls_categories on the block builder screen only, and the type dropdown walks it in array order. That order is the order the sections appear in. A section with no controls in it is skipped, and a control whose category is not a key here never appears in the dropdown at all.
Attributes
| Name | Type | Description |
|---|---|---|
$categories | Array | category labels, keyed by category slug |
Labels are shown to the user, so run new ones through a translation function.
Usage
function my_lzb_controls_categories( $categories ) {
// Put a section for the theme's own controls above Basic, and move the
// deprecated ones out of sight.
unset( $categories['deprecated'] );
return array_merge(
array( 'theme' => __( 'Theme Controls', 'my-theme' ) ),
$categories,
array( 'deprecated' => __( 'Deprecated', 'lazy-blocks' ) )
);
}
add_filter( 'lzb/controls/categories', 'my_lzb_controls_categories' );Removing a category that controls still point at hides those controls from the picker without removing the controls themselves, so blocks already using them keep working and nobody can add another. Assign the new slug to a control through its category key in lzb/controls/all, or through the $category property when you subclass LazyBlocks_Control.
Building a control of your own is covered in Create Custom Control.