PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/style-engine/style-engine-gutenberg.php +12 -6 23.3.0 → 24.1.0 View file →
@@ -21,9 +21,9 @@
21 21 *
22 22 * @since 6.1.0
23 23 *
24 24 * @param array $block_styles The style object.
25 - * @param array $options {
25 + * @param array $options {
26 26 * Optional. An array of options. Default empty array.
27 27 *
28 28 * @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is `null`.
29 29 * When set, the Style Engine will attempt to store the CSS rules, where a selector is also passed.
@@ -84,12 +84,13 @@
84 84 *
85 85 * @type array ...$0 {
86 86 * @type string $rules_group A parent CSS selector in the case of nested CSS, or a CSS nested @rule, such as `@media (min-width: 80rem)` or `@layer module`.
87 87 * @type string $selector A CSS selector.
88 - * @type string[] $declarations An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
88 + * @type string[]|WP_Style_Engine_CSS_Declarations_Gutenberg $declarations An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ),
89 + * or a WP_Style_Engine_CSS_Declarations_Gutenberg object.
89 90 * }
90 91 * }
91 - * @param array $options {
92 + * @param array $options {
92 93 * Optional. An array of options. Default empty array.
93 94 *
94 95 * @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
95 96 * When set, the Style Engine will attempt to store the CSS rules.
@@ -112,18 +113,23 @@
112 113 );
113 114
114 115 $css_rule_objects = array();
115 116 foreach ( $css_rules as $css_rule ) {
116 - if ( empty( $css_rule['selector'] ) || empty( $css_rule['declarations'] ) || ! is_array( $css_rule['declarations'] ) ) {
117 + $declarations = $css_rule['declarations'] ?? null;
118 + if (
119 + empty( $css_rule['selector'] ) ||
120 + empty( $declarations ) ||
121 + ( ! is_array( $declarations ) && ! $declarations instanceof WP_Style_Engine_CSS_Declarations_Gutenberg )
122 + ) {
117 123 continue;
118 124 }
119 125
120 126 $rules_group = $css_rule['rules_group'] ?? null;
121 127 if ( ! empty( $options['context'] ) ) {
122 - WP_Style_Engine_Gutenberg::store_css_rule( $options['context'], $css_rule['selector'], $css_rule['declarations'], $rules_group );
128 + WP_Style_Engine_Gutenberg::store_css_rule( $options['context'], $css_rule['selector'], $declarations, $rules_group );
123 129 }
124 130
125 - $css_rule_objects[] = new WP_Style_Engine_CSS_Rule_Gutenberg( $css_rule['selector'], $css_rule['declarations'], $rules_group );
131 + $css_rule_objects[] = new WP_Style_Engine_CSS_Rule_Gutenberg( $css_rule['selector'], $declarations, $rules_group );
126 132 }
127 133
128 134 if ( empty( $css_rule_objects ) ) {
129 135 return '';