This documentation describes unreleased changes on the main branch.

#[BlockSupport]

Attribute on classes.

use Saij\WpAppFramework\Block\Support\BlockSupport;

Declares a custom block support: blocks of the same theme or plugin that use it with #[UseSupport] get an attribute, a control in the inspector and the class names it returns on their root element.

The class is a service with a public method className(). Its only parameter is the value of the attribute: its type (int, float, string, bool or a backed enum, optionally nullable) derives the schema and the control, its default is the default of the attribute. The method returns the class names for the value (separated by spaces), or null or '' for none; it runs while the block renders, so the service may depend on other services.

Arguments

#[BlockSupport(string $attribute, string $label, SupportGroup $group = SupportGroup::Styles)]
ParameterTypeDefaultDescription
attributestringrequiredName of the block attribute, in camelCase (e.g. "colorScheme").
labelstringrequiredLabel of the control in the inspector.
groupSupportGroupSupportGroup::StylesWhere the inspector shows the control.