WP_Duotone::register_duotone_support( WP_Block_Type $block_type )

Registers the style and colors block attributes for block types that support it.

Description

Block support is added with supports.filter.duotone in block.json.

Parameters

$block_typeWP_Block_Typerequired
Block Type.

Source

public static function register_duotone_support( $block_type ) {
	/*
	 * Previous `color.__experimentalDuotone` support flag is migrated
	 * to `filter.duotone` via `block_type_metadata_settings` filter.
	 */
	if ( block_has_support( $block_type, array( 'filter', 'duotone' ), null ) ) {
		if ( ! $block_type->attributes ) {
			$block_type->attributes = array();
		}

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

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.