WP_Duotone::enqueue_block_css
Enqueue a block CSS declaration for the page.
This does not include any SVGs.
Method of the class: WP_Duotone{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = WP_Duotone::enqueue_block_css( $filter_id, $duotone_selector, $filter_value );
- $filter_id(string) (required)
- The filter ID. e.g.
'wp-duotone-000000-ffffff-2'. - $duotone_selector(string) (required)
- The block's duotone selector. e.g.
'.wp-block-image img'. - $filter_value(string) (required)
- The filter CSS value. e.g.
'url(#wp-duotone-000000-ffffff-2)'or'unset'.
Changelog
| Since 6.3.0 | Introduced. |
WP_Duotone::enqueue_block_css() WP Duotone::enqueue block css code WP 6.9.1
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,
),
);
}