WP_Duotone::get_selector()private staticWP 6.3.0

Get the CSS selector for a block type.

This handles selectors defined in color.__experimentalDuotone support if filter.duotone support is not defined.

Метод класса: WP_Duotone{}

Хуков нет.

Возвращает

Строку|null. The CSS selector or null if there is no support.

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

$result = WP_Duotone::get_selector( $block_type );
$block_type(WP_Block_Type) (обязательный)
Block type to check for support.

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

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

Код WP_Duotone::get_selector() WP 6.6.2

private static function get_selector( $block_type ) {
	if ( ! ( $block_type instanceof WP_Block_Type ) ) {
		return null;
	}

	/*
	 * Backward compatibility with `supports.color.__experimentalDuotone`
	 * is provided via the `block_type_metadata_settings` filter. If
	 * `supports.filter.duotone` has not been set and the experimental
	 * property has been, the experimental property value is copied into
	 * `supports.filter.duotone`.
	 */
	$duotone_support = block_has_support( $block_type, array( 'filter', 'duotone' ) );
	if ( ! $duotone_support ) {
		return null;
	}

	/*
	 * If the experimental duotone support was set, that value is to be
	 * treated as a selector and requires scoping.
	 */
	$experimental_duotone = isset( $block_type->supports['color']['__experimentalDuotone'] )
		? $block_type->supports['color']['__experimentalDuotone']
		: false;
	if ( $experimental_duotone ) {
		$root_selector = wp_get_block_css_selector( $block_type );
		return is_string( $experimental_duotone )
			? WP_Theme_JSON::scope_selector( $root_selector, $experimental_duotone )
			: $root_selector;
	}

	// Regular filter.duotone support uses filter.duotone selectors with fallbacks.
	return wp_get_block_css_selector( $block_type, array( 'filter', 'duotone' ), true );
}