Skip to content

Commit

Permalink
Update packages/style-engine/class-wp-style-engine.php
Browse files Browse the repository at this point in the history
Co-authored-by: Ari Stathopoulos <[email protected]>
  • Loading branch information
ramonjd and aristath committed Jul 28, 2022
1 parent b0a5ac7 commit ab948d8
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions packages/style-engine/class-wp-style-engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -659,34 +659,34 @@ public static function compile_stylesheet_from_store( $store_key ) {
* );
*/
function wp_style_engine_get_styles( $block_styles, $options = array() ) {
if ( class_exists( 'WP_Style_Engine' ) ) {
$defaults = array(
'selector' => null,
'convert_vars_to_classnames' => false,
'enqueue' => false,
);

$options = wp_parse_args( $options, $defaults );
$style_engine = WP_Style_Engine::get_instance();
$parsed_styles = $style_engine->parse_block_supports_styles( $block_styles, $options );

// Output.
$styles_output = array();
if ( ! empty( $parsed_styles['css_declarations'] ) ) {
$styles_output['css'] = $style_engine->compile_css( $parsed_styles['css_declarations'], $options['selector'] );
$styles_output['declarations'] = $parsed_styles['css_declarations'];
if ( true === $options['enqueue'] ) {
$style_engine::store_css_rule( $options['selector'], $parsed_styles['css_declarations'], 'block-supports' );
}
}
if ( ! class_exists( 'WP_Style_Engine' ) ) {
return array();
}
$defaults = array(
'selector' => null,
'convert_vars_to_classnames' => false,
'enqueue' => false,
);

if ( ! empty( $parsed_styles['classnames'] ) ) {
$styles_output['classnames'] = $style_engine->compile_classnames( $parsed_styles['classnames'] );
$options = wp_parse_args( $options, $defaults );
$style_engine = WP_Style_Engine::get_instance();
$parsed_styles = $style_engine->parse_block_supports_styles( $block_styles, $options );

// Output.
$styles_output = array();
if ( ! empty( $parsed_styles['css_declarations'] ) ) {
$styles_output['css'] = $style_engine->compile_css( $parsed_styles['css_declarations'], $options['selector'] );
$styles_output['declarations'] = $parsed_styles['css_declarations'];
if ( true === $options['enqueue'] ) {
$style_engine::store_css_rule( $options['selector'], $parsed_styles['css_declarations'], 'block-supports' );
}
}

return array_filter( $styles_output );
if ( ! empty( $parsed_styles['classnames'] ) ) {
$styles_output['classnames'] = $style_engine->compile_classnames( $parsed_styles['classnames'] );
}
return array();

return array_filter( $styles_output );
}

/**
Expand Down

0 comments on commit ab948d8

Please sign in to comment.