Skip to content
PHP Filters

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.

SlugLabel
basicBasic
contentContent
choiceChoice
advancedAdvanced
layoutLayout
deprecatedDeprecated

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

NameTypeDescription
$categoriesArraycategory labels, keyed by category slug

Labels are shown to the user, so run new ones through a translation function.

Usage

PHP
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.

Was this article helpful?

Copyright © 2026 Lazy Blocks.