Skip to content

Commit

Permalink
Reverting changes and updated doc comment blocks.
Browse files Browse the repository at this point in the history
The reason for revert is that `wp_typography_get_css_variable_inline_style` was only deprecated in 6.1, and the Gutenberg plugin supports a minimum of 6.0.
  • Loading branch information
ramonjd committed Dec 19, 2022
1 parent ded9354 commit 5d8fc2c
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions lib/block-supports/typography.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,34 @@ function gutenberg_apply_typography_support( $block_type, $block_attributes ) {
}

/**
* Note: this method is for backwards compatibility.
* It mostly replaces `gutenberg_typography_get_css_variable_inline_style()`.
*
* Generates an inline style value for a typography feature e.g. text decoration,
* text transform, and font style.
*
* @param string $style_value A raw style value for a single typography feature from a block's style attribute.
* @param string $css_property Slug for the CSS property the inline style sets.
* Note: This function is for backwards compatibility.
* * It is necessary to parse older blocks whose typography styles contain presets.
* * It mostly replaces the deprecated `wp_typography_get_css_variable_inline_style()`,
* but skips compiling a CSS declaration as the style engine takes over this role.
*
* @link https://github.com/wordpress/gutenberg/pull/27555
*
* @since 6.1.0
*
* @return string? A CSS inline style value.
* @param string $style_value A raw style value for a single typography feature from a block's style attribute.
* @param string $css_property Slug for the CSS property the inline style sets.
* @return string A CSS inline style value.
*/
function gutenberg_typography_get_preset_inline_style_value( $style_value, $css_property ) {
// If the style value is not a preset CSS variable go no further.
if ( empty( $style_value ) || ! str_contains( $style_value, "var:preset|{$css_property}|" ) ) {
return $style_value;
}

// For backwards compatibility.
// Presets were removed in https://github.com/WordPress/gutenberg/pull/27555.
// We have a preset CSS variable as the style.
// Get the style value from the string and return CSS style.
/*
* For backwards compatibility.
* Presets were removed in WordPress/gutenberg#27555.
* We have a preset CSS variable as the style.
* Get the style value from the string and return CSS style.
*/
$index_to_splice = strrpos( $style_value, '|' ) + 1;
$slug = _wp_to_kebab_case( substr( $style_value, $index_to_splice ) );

Expand All @@ -197,14 +204,16 @@ function gutenberg_typography_get_preset_inline_style_value( $style_value, $css_
}

/**
* Deprecated.
* This method is no longer used and will have to be deprecated in Core.
* This method is no longer used and has been deprecated in Core since 6.1.0.
*
* It can be deleted once migrated to the next WordPress version.
* It can be deleted once Gutenberg's minimum supported WordPress version is >= 6.1
*
* Generates an inline style for a typography feature e.g. text decoration,
* text transform, and font style.
*
* @since 5.8.0
* @deprecated 6.1.0
*
* @param array $attributes Block's attributes.
* @param string $feature Key for the feature within the typography styles.
* @param string $css_property Slug for the CSS property the inline style sets.
Expand Down

1 comment on commit 5d8fc2c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3729026713
📝 Reported issues:

Please sign in to comment.