Automattic\WooCommerce\Admin\Features\ProductBlockEditor

Init::register_metadata_attribute()publicWC 1.0

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.

Return

Array. $args

Usage

$Init = new Init();
$Init->register_metadata_attribute( $args );
$args(array) (required)
Array of arguments for registering a block type.

Notes

Init::register_metadata_attribute() code WC 9.7.1

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;
}