WP_Duotone::enqueue_block_css( string $filter_id, string $duotone_selector, string $filter_value )

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Enqueue a block CSS declaration for the page.


This does not include any SVGs.


The filter ID. e.g. 'wp-duotone-000000-ffffff-2'.
The block’s duotone selector. e.g. ‘.wp-block-image img’.
The filter CSS value. e.g. 'url(#wp-duotone-000000-ffffff-2)' or 'unset'.


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,



User Contributed Notes

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