Skip to content

Commit

Permalink
Move gutenberg_render_duotone_support @deprecated annotation up
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Lende authored and scruffian committed Apr 18, 2023
1 parent d7f1d31 commit 6adec60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
8 changes: 3 additions & 5 deletions lib/block-supports/duotone.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,7 @@ function gutenberg_tinycolor_string_to_rgb( $color_str ) {
*/
function gutenberg_get_duotone_filter_id( $preset ) {
_deprecated_function( __FUNCTION__, '6.3.0' );
if ( ! isset( $preset['slug'] ) ) {
return '';
}
return WP_Duotone_Gutenberg::get_filter_id( $preset['slug'] );
return WP_Duotone_Gutenberg::get_filter_id_from_preset( $preset );
}

/**
Expand Down Expand Up @@ -404,9 +401,10 @@ function gutenberg_register_duotone_support( $block_type ) {
/**
* Render out the duotone stylesheet and SVG.
*
* @deprecated 6.3.0 Use WP_Duotone_Gutenberg::render_duotone_support() instead.
*
* @param string $block_content Rendered block content.
* @param array $block Block object.
* @deprecated 6.3.0 Use WP_Duotone_Gutenberg::render_duotone_support() instead.
* @return string Filtered block content.
*/
function gutenberg_render_duotone_support( $block_content, $block ) {
Expand Down
24 changes: 16 additions & 8 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -902,16 +902,27 @@ public static function migrate_experimental_duotone_support_flag( $settings, $me
}

/**
* Gets the SVG for the duotone filter definition from a preset.
* Returns the prefixed id for the duotone filter for use as a CSS id.
*
* @param array $preset The duotone preset.
* @return string The SVG for the filter definition.
* @param array $preset Duotone preset value as seen in theme.json.
* @return string Duotone filter CSS id.
*/
public static function get_filter_svg_from_preset( $preset ) {
public static function get_filter_id_from_preset( $preset ) {
$filter_id = '';
if ( isset( $preset['slug'] ) ) {
$filter_id = self::get_filter_id( $preset['slug'] );
}
return $filter_id;
}

/**
* Gets the SVG for the duotone filter definition from a preset.
*
* @param array $preset The duotone preset.
* @return string The SVG for the filter definition.
*/
public static function get_filter_svg_from_preset( $preset ) {
$filter_id = self::get_filter_id_from_preset( $preset );
return self::get_filter_svg( $filter_id, $preset['colors'] );
}

Expand All @@ -926,10 +937,7 @@ public static function get_filter_css_property_value_from_preset( $preset ) {
return $preset['colors'];
}

$filter_id = '';
if ( isset( $preset['slug'] ) ) {
$filter_id = self::get_filter_id( $preset['slug'] );
}
$filter_id = self::get_filter_id_from_preset( $preset );

return 'url(#' . $filter_id . ')';
}
Expand Down

0 comments on commit 6adec60

Please sign in to comment.