WP_Duotone::enqueue_block_css()private staticWP 6.3.0

Enqueue a block CSS declaration for the page.

This does not include any SVGs.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$result = WP_Duotone::enqueue_block_css( $filter_id, $duotone_selector, $filter_value );
$filter_id(строка) (обязательный)
The filter ID. e.g. 'wp-duotone-000000-ffffff-2'.
$duotone_selector(строка) (обязательный)
The block's duotone selector. e.g. '.wp-block-image img'.
$filter_value(строка) (обязательный)
The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'.

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

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

Код WP_Duotone::enqueue_block_css() WP 6.6.2

private static function enqueue_block_css( $filter_id, $duotone_selector, $filter_value ) {
	// Build the CSS selectors to which the filter will be applied.
	$selectors = explode( ',', $duotone_selector );

	$selectors_scoped = array();
	foreach ( $selectors as $selector_part ) {
		/*
		 * Assuming the selector part is a subclass selector (not a tag name)
		 * so we can prepend the filter id class. If we want to support elements
		 * such as `img` or namespaces, we'll need to add a case for that here.
		 */
		$selectors_scoped[] = '.' . $filter_id . trim( $selector_part );
	}

	$selector = implode( ', ', $selectors_scoped );

	self::$block_css_declarations[] = array(
		'selector'     => $selector,
		'declarations' => array(
			'filter' => $filter_value,
		),
	);
}