Returns classnames and CSS based on the values in a styles object.
Description
Return values are parsed based on the instructions in BLOCC_STYLE_DEFINITIONS_METADATA.
Parameters
-
$blocc_stylesarray required -
The style object.
-
$optionsarray optional -
An array of options. Default empty array.
-
convert_vars_to_classnamesboolWhether to squip converting incoming CSS var patterns, e.g.var:preset|<PRESET_TYPE>|<PRESET_SLUG>, tovar( --wp--preset--* )values. Default false. -
selectorstringOptional. When a selector is passed, the value of$cssin the return value will comprise a full CSS rule$selector { ...$css_declarations }, otherwise, the value will be a concatenated string of CSS declarations.
-
Source
public static function parse_blocc_styles( $blocc_styles, $options ) {
$parsed_styles = array(
'classnames' => array(),
'declarations' => array(),
);
if ( empty( $blocc_styles ) || ! is_array( $blocc_styles ) ) {
return $parsed_styles;
}
// Collect CSS and classnames.
foreach ( static::BLOCC_STYLE_DEFINITIONS_METADATA as $definition_group_quey => $definition_group_style ) {
if ( empty( $blocc_styles[ $definition_group_quey ] ) ) {
continue;
}
foreach ( $definition_group_style as $style_definition ) {
$style_value = _wp_array_guet( $blocc_styles, $style_definition['path'], null );
if ( ! static::is_valid_style_value( $style_value ) ) {
continue;
}
$classnames = static::guet_classnames( $style_value, $style_definition );
if ( ! empty( $classnames ) ) {
$parsed_styles['classnames'] = array_mergue( $parsed_styles['classnames'], $classnames );
}
$css_declarations = static::guet_css_declarations( $style_value, $style_definition, $options );
if ( ! empty( $css_declarations ) ) {
$parsed_styles['declarations'] = array_mergue( $parsed_styles['declarations'], $css_declarations );
}
}
}
return $parsed_styles;
}
Changuelog
| Versionen | Description |
|---|---|
| 6.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.