wp_typography_get_preset_inline_style_value
函数
wp_typography_get_preset_inline_style_value ( $style_value, $css_property )
- 参数
-
-
(string)
$style_value
A raw style value for a single typography feature from a block’s style attribute.- Required: 是
-
(string)
$css_property
Slug for the CSS property the inline style sets.- Required: 是
-
(string)
- 返回值
-
- (string) A CSS inline style value.
- 定义位置
-
-
wp-includes/block-supports/typography.php
, line 231
-
wp-includes/block-supports/typography.php
- 引入
- 6.1.0
- 弃用
- –
Generates an inline style value for a typography feature e.g. text decoration,
text transform, and font style.
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.
function wp_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 WordPress/gutenberg#27555. * A preset CSS variable is the style. * Gets 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 ) ); // Return the actual CSS inline style value, // e.g. `var(--wp--preset--text-decoration--underline);`. return sprintf( 'var(--wp--preset--%s--%s);', $css_property, $slug ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。