Enqueue a block CSS declaration for the page.
Description
This does not include any SVGs.
Parameters
$filter_id
stringrequired- The filter ID. e.g.
'wp-duotone-000000-ffffff-2'
. $duotone_selector
stringrequired- The block’s duotone selector. e.g. ‘.wp-block-image img’.
$filter_value
stringrequired- The filter CSS value. e.g.
'url(#wp-duotone-000000-ffffff-2)'
or'unset'
.
Source
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,
),
);
}
Changelog
Version | Description |
---|---|
6.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.