wp-includes/style-engine.php:63$styles = wp_style_engine_get_styles(
array(
'color' => array( 'text' => '#cccccc' ),
)
); Returns: array(
'css' => 'color: #cccccc',
'declarations' => array( 'color' => '#cccccc' ),
'classnames' => 'has-color',
)$block_stylesarray$optionsarrayoptionalarray()$contextstring|null
$convert_vars_to_classnamesbooldefault: false
var:preset|<PRESET_TYPE>|<PRESET_SLUG>, to var( --wp--preset--* ) values.$selectorstring
$css in the return value will comprise a full CSS rule $selector { ...$css_declarations }, otherwise, the value will be a concatenated string of CSS declarations.arraystyle attribute or tag.$declarationsstring[]
array( "$property" => "$value", "$property" => "$value" ).$classnamesstring
function wp_style_engine_get_styles( $block_styles, $options = array() ) { $options = wp_parse_args( $options, array( 'selector' => null, 'context' => null, 'convert_vars_to_classnames' => false, ) ); $parsed_styles = WP_Style_Engine::parse_block_styles( $block_styles, $options ); // Output. $styles_output = array(); if ( ! empty( $parsed_styles['declarations'] ) ) { $styles_output['css'] = WP_Style_Engine::compile_css( $parsed_styles['declarations'], $options['selector'] ); $styles_output['declarations'] = $parsed_styles['declarations']; if ( ! empty( $options['context'] ) ) { WP_Style_Engine::store_css_rule( $options['context'], $options['selector'], $parsed_styles['declarations'] ); } } if ( ! empty( $parsed_styles['classnames'] ) ) { $styles_output['classnames'] = implode( ' ', array_unique( $parsed_styles['classnames'] ) ); } return array_filter( $styles_output );}Introduced in 6.1.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/style-engine.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.