wp_register_dimensions_support()WP 5.9.0

Registers the style block attribute for block types that support it.

Хуков нет.

Возвращает

null. Ничего.

Использование

wp_register_dimensions_support( $block_type );
$block_type(WP_Block_Type) (обязательный)
Block Type.

Список изменений

С версии 5.9.0 Введена.

Код wp_register_dimensions_support() WP 6.0

function wp_register_dimensions_support( $block_type ) {
	// Setup attributes and styles within that if needed.
	if ( ! $block_type->attributes ) {
		$block_type->attributes = array();
	}

	// Check for existing style attribute definition e.g. from block.json.
	if ( array_key_exists( 'style', $block_type->attributes ) ) {
		return;
	}

	$has_dimensions_support = block_has_support( $block_type, array( '__experimentalDimensions' ), false );
	// Future block supports such as height & width will be added here.

	if ( $has_dimensions_support ) {
		$block_type->attributes['style'] = array(
			'type' => 'object',
		);
	}
}