Parsed: 131766

function wp_style_engine_get_stylesheet_from_css_rules( $css_rules, $options = array() ) {
  if ( empty( $css_rules ) ) {
    return '';
  }

  $options = wp_parse_args(
    $options,
    array(
      'context' => null,
    )
  );

  $css_rule_objects = array();
  foreach ( $css_rules as $css_rule ) {
    if ( empty( $css_rule['selector'] ) || empty( $css_rule['declarations'] ) || ! is_array( $css_rule['declarations'] ) ) {
      continue;
    }

    if ( ! empty( $options['context'] ) ) {
      WP_Style_Engine::store_css_rule( $options['context'], $css_rule['selector'], $css_rule['declarations'] );
    }

    $css_rule_objects[] = new WP_Style_Engine_CSS_Rule( $css_rule['selector'], $css_rule['declarations'] );
  }

  if ( empty( $css_rule_objects ) ) {
    return '';
  }

  return WP_Style_Engine::compile_stylesheet_from_css_rules( $css_rule_objects, $options );
}