lzb_pro/rich_text/names
Declares the <RichText /> names of a block that the static parser cannot find.
Lazy Blocks Pro finds the component by scanning the block code for <RichText name="..." /> tags. A block using the PHP output method builds those tags at runtime, inside a loop or a conditional, so the scan comes back empty and the names never get registered as block attributes. List them here instead.
Attributes
| Name | Type | Description |
|---|---|---|
$names | Array | component names found in the block code, a flat list of strings |
$block | Array | block data |
Three things read the result:
| Where | What it does with the names |
|---|---|
register_block_attributes() | registers each name as a string block attribute, unless a control already registers it, the name is reserved, or it belongs to a Save in Meta control |
get_translatable_names() | offers the names without a control behind them to WPML through lzb/wpml/translated_attributes |
get_exclusive_names() | works out which names the component alone renders, so the editor can skip the server round trip while typing |
Usage
function my_lzb_pro_rich_text_names( $names, $block ) {
if ( 'lazyblock/team-member' !== $block['slug'] ) {
return $names;
}
// The tags are printed from a foreach in the PHP output method, so the
// scan of the block code never sees these two names.
$names[] = 'member-name';
$names[] = 'member-role';
return array_values( array_unique( $names ) );
}
add_filter( 'lzb_pro/rich_text/names', 'my_lzb_pro_rich_text_names', 10, 2 );Return a flat array of strings. The names are used as array keys and as block attribute names, so a nested array or an associative one breaks attribute registration.
Eight names are dropped further down whatever this filter returns: lazyblock, className, align, anchor, blockId, blockUniqueClass, ghostkitSpacings and ghostkitSR. They belong to the plugin and to block supports, and the front end refuses to print them too.
A name that never reaches this list is not registered as an attribute, so whatever a person types into it is dropped the moment the post is saved. The component itself is covered in Rich Text.