Automattic\WooCommerce\Admin\Features\ProductBlockEditor
Init::register_metadata_attribute
Registers the metadata block attribute for all block types. This is a fallback/temporary solution until the Gutenberg core version registers the metadata attribute.
Method of the class: Init{}
No Hooks.
Returns
Array. $args
Usage
$Init = new Init(); $Init->register_metadata_attribute( $args );
- $args(array) (required)
- Array of arguments for registering a block type.
Notes
- See: https://github.com/WordPress/gutenberg/blob/6aaa3686ae67adc1a6a6b08096d3312859733e1b/lib/compat/wordpress-6.5/blocks.php#L27-L47
To do: Remove this method once the Gutenberg core version registers the metadata attribute.
Init::register_metadata_attribute() Init::register metadata attribute code WC 10.4.3
public function register_metadata_attribute( $args ) {
// Setup attributes if needed.
if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
$args['attributes'] = array();
}
// Add metadata attribute if it doesn't exist.
if ( ! array_key_exists( 'metadata', $args['attributes'] ) ) {
$args['attributes']['metadata'] = array(
'type' => 'object',
);
}
return $args;
}