diff --git a/lib/block-supports/duotone.php b/lib/block-supports/duotone.php
index 5869d521b2d380..5d507ea051ee05 100644
--- a/lib/block-supports/duotone.php
+++ b/lib/block-supports/duotone.php
@@ -251,31 +251,17 @@ function gutenberg_register_duotone_support( $block_type ) {
}
/**
- * Render out the duotone stylesheet and SVG.
+ * Renders the duotone filter SVG and returns the CSS filter property to
+ * reference the rendered SVG.
*
- * @param string $block_content Rendered block content.
- * @param array $block Block object.
- * @return string Filtered block content.
+ * @param array $preset Duotone preset value as seen in theme.json.
+ *
+ * @return string Duotone CSS filter property.
*/
-function gutenberg_render_duotone_support( $block_content, $block ) {
- $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] );
-
- $duotone_support = false;
- if ( $block_type && property_exists( $block_type, 'supports' ) ) {
- $duotone_support = _wp_array_get( $block_type->supports, array( 'color', '__experimentalDuotone' ), false );
- }
-
- $has_duotone_attribute = isset( $block['attrs']['style']['color']['duotone'] );
-
- if (
- ! $duotone_support ||
- ! $has_duotone_attribute
- ) {
- return $block_content;
- }
-
- $duotone_colors = $block['attrs']['style']['color']['duotone'];
-
+function gutenberg_render_duotone_filter_preset( $preset ) {
+ $duotone_id = $preset['slug'];
+ $duotone_colors = $preset['colors'];
+ $filter_id = 'wp-duotone-' . $duotone_id;
$duotone_values = array(
'r' => array(),
'g' => array(),
@@ -289,29 +275,12 @@ function gutenberg_render_duotone_support( $block_content, $block ) {
$duotone_values['b'][] = $color['b'] / 255;
}
- $duotone_id = 'wp-duotone-filter-' . uniqid();
-
- $selectors = explode( ',', $duotone_support );
- $selectors_scoped = array_map(
- function ( $selector ) use ( $duotone_id ) {
- return '.' . $duotone_id . ' ' . trim( $selector );
- },
- $selectors
- );
- $selectors_group = implode( ', ', $selectors_scoped );
-
ob_start();
?>
-
-