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.
Метод класса: Init{}
Хуков нет.
Возвращает
Массив
. $args
Использование
$Init = new Init(); $Init->register_metadata_attribute( $args );
- $args(массив) (обязательный)
- Array of arguments for registering a block type.
Заметки
- Смотрите: 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 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; }