lzb/wpml/translated_attributes
Filters the block attributes handed to WPML for translation.
Lazy Blocks builds this list from the controls whose Translate setting is on. Use the filter to add an attribute your own code stores on the block, which has no control behind it and so would never reach WPML on its own.
Attributes
| Name | Type | Description |
|---|---|---|
$translated_controls | Array | WPML config nodes for this block |
$block | Array | block data |
Each item is a WPML config node rather than a plain attribute name. A single attribute looks like this:
array(
'value' => '',
'attr' => array(
'name' => 'my-attribute',
),
)An attribute holding a JSON array, the shape a Repeater control produces, nests its inner attributes under a * key:
array(
'value' => '',
'attr' => array(
'name' => 'my-repeater',
'encoding' => 'json',
),
'key' => array(
'value' => '',
'attr' => array(
'name' => '*',
),
'key' => array(
array(
'value' => '',
'attr' => array( 'name' => 'inner-attribute' ),
),
),
),
)Usage
function my_lzb_wpml_translated_attributes( $translated_controls, $block ) {
if ( 'my-block' !== $block['slug'] ) {
return $translated_controls;
}
$translated_controls[] = array(
'value' => '',
'attr' => array(
'name' => 'my-attribute',
),
);
return $translated_controls;
}
add_filter( 'lzb/wpml/translated_attributes', 'my_lzb_wpml_translated_attributes', 10, 2 );Returning an empty array keeps the block out of the generated WPML configuration entirely.
See Multilingual for how Lazy Blocks and WPML work together.