#[Variation]

Attribute on classes, repeatable.

use Saij\WpAppFramework\Block\Variation;

A variation of a block: preset attributes and inner blocks the editor offers under their own title. The content stores the block itself.

Arguments

#[Variation(string $name, string $title, string $icon = '', string $description = '', array $keywords = [], array $attributes = [], array $innerBlocks = [], array $scope = [VariationScope::Inserter, VariationScope::Block], bool $isDefault = false, array $isActive = [])]
ParameterTypeDefaultDescription
namestringrequiredUnique within the block: lowercase letters, digits and "-".
titlestringrequiredTitle of the variation in the inserter; must not be empty.
iconstring''Name of a Dashicon, e.g. cover-image; '' for the icon of the block.
descriptionstring''Description shown in the inserter and the block inspector.
keywordslist<string>[]Search terms for the inserter.
attributesarray<string, mixed>[]Preset attribute values; backed enums stand for their value.
innerBlockslist<TemplateBlock>[]Preset inner blocks.
scopelist<VariationScope>[VariationScope::Inserter, VariationScope::Block]Where the editor offers the variation.
isDefaultboolfalseReplaces the block itself in the inserter.
isActivelist<string>[]Attributes by which the editor recognizes the variation of a block (its title and icon in the block card and the list view); each must be preset in $attributes.