Automattic\WooCommerce\Admin\Features\ProductBlockEditor
BlockRegistry::augment_attributes
Augment the attributes of a block by adding attributes that are used by the product editor.
Method of the class: BlockRegistry{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->augment_attributes( $attributes );
- $attributes(array) (required)
- Block attributes.
BlockRegistry::augment_attributes() BlockRegistry::augment attributes code WC 10.5.0
private function augment_attributes( $attributes ) {
global $wp_version;
// Note: If you modify this function, also update the client-side
// registerWooBlockType function in @woocommerce/block-templates.
$augmented_attributes = array_merge(
$attributes,
array(
'_templateBlockId' => array(
'type' => 'string',
'role' => 'content',
),
'_templateBlockOrder' => array(
'type' => 'integer',
'role' => 'content',
),
'_templateBlockHideConditions' => array(
'type' => 'array',
'role' => 'content',
),
'_templateBlockDisableConditions' => array(
'type' => 'array',
'role' => 'content',
),
'disabled' => isset( $attributes['disabled'] ) ? $attributes['disabled'] : array(
'type' => 'boolean',
'role' => 'content',
),
)
);
if ( ! $this->has_role_support() ) {
foreach ( $augmented_attributes as $key => $attribute ) {
if ( isset( $attribute['role'] ) ) {
$augmented_attributes[ $key ]['__experimentalRole'] = $attribute['role'];
}
}
}
return $augmented_attributes;
}