You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/wp-includes/style-engine.php
+48-34Lines changed: 48 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -25,19 +25,22 @@
25
25
* @access public
26
26
* @since 6.1.0
27
27
*
28
-
* @param array $block_styles The style object.
29
-
* @param array<string|boolean> $options array(
30
-
* 'context' => (string|null) An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
31
-
* When set, the style engine will attempt to store the CSS rules, where a selector is also passed.
32
-
* 'convert_vars_to_classnames' => (boolean) Whether to skip converting CSS var:? values to var( --wp--preset--* ) values. Default is `false`.
33
-
* 'selector' => (string) When a selector is passed, `generate()` will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
34
-
* );.
35
-
*
36
-
* @return array<string|array> array(
37
-
* 'css' => (string) A CSS ruleset or declarations block formatted to be placed in an HTML `style` attribute or tag.
38
-
* 'declarations' => (array) An array of property/value pairs representing parsed CSS declarations.
39
-
* 'classnames' => (string) Classnames separated by a space.
40
-
* );
28
+
* @param array $block_styles The style object.
29
+
* @param array $options {
30
+
* Optional. An array of options. Default empty array.
31
+
*
32
+
* @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is `null`.
33
+
* When set, the style engine will attempt to store the CSS rules, where a selector is also passed.
34
+
* @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to var( --wp--preset--* ) values. Default `false`.
35
+
* @type string $selector Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
36
+
* otherwise, the value will be a concatenated string of CSS declarations.
37
+
* }
38
+
*
39
+
* @return array {
40
+
* @type string $css A CSS ruleset or declarations block formatted to be placed in an HTML `style` attribute or tag.
41
+
* @type array<string, string> $declarations An array of property/value pairs representing parsed CSS declarations.
42
+
* @type string $classnames Classnames separated by a space.
* declarations' => (boolean) An array of CSS definitions, e.g., array( "$property" => "$value" ).
87
-
* )
88
-
* );.
89
-
* @param array<string> $options array(
90
-
* 'context' => (string|null) An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
91
-
* When set, the style engine will attempt to store the CSS rules.
92
-
* 'optimize' => (boolean) Whether to optimize the CSS output, e.g., combine rules.
93
-
* 'prettify' => (boolean) Whether to add new lines to output.
94
-
* );.
91
+
* @param array $css_rules {
92
+
* Required. A collection of CSS rules.
93
+
*
94
+
* @type array ...$0 {
95
+
* @type string $selector A CSS selector.
96
+
* @type array<string, string> $declarations An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
97
+
* }
98
+
* }
99
+
* @param array $options {
100
+
* Optional. An array of options. Default empty array.
101
+
*
102
+
* @type string|null $context An identifier describing the origin of the style object, e.g., 'block-supports' or 'global-styles'. Default is 'block-supports'.
103
+
* When set, the style engine will attempt to store the CSS rules.
104
+
* @type boolean $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
105
+
* @type boolean $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
106
+
* }
95
107
*
96
108
* @return string A compiled CSS string.
97
109
*/
@@ -133,18 +145,20 @@ function wp_style_engine_get_stylesheet_from_css_rules( $css_rules, $options = a
133
145
* @access public
134
146
* @since 6.1.0
135
147
*
136
-
* @param string $store_name A valid store name.
137
-
* @param array $options array(
138
-
* 'optimize' => (boolean) Whether to optimize the CSS output, e.g., combine rules.
139
-
* 'prettify' => (boolean) Whether to add new lines to output.
140
-
* );.
148
+
* @param string $context A valid context name, corresponding to an existing store key.
149
+
* @param array $options {
150
+
* Optional. An array of options. Default empty array.
151
+
*
152
+
* @type boolean $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
153
+
* @type boolean $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
Copy file name to clipboardExpand all lines: src/wp-includes/style-engine/class-wp-style-engine-processor.php
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -63,6 +63,7 @@ public function add_rules( $css_rules ) {
63
63
if ( ! is_array( $css_rules ) ) {
64
64
$css_rules = array( $css_rules );
65
65
}
66
+
66
67
foreach ( $css_rulesas$rule ) {
67
68
$selector = $rule->get_selector();
68
69
if ( isset( $this->css_rules[ $selector ] ) ) {
@@ -80,10 +81,12 @@ public function add_rules( $css_rules ) {
80
81
*
81
82
* @since 6.1.0
82
83
*
83
-
* @param array $options array(
84
-
* 'optimize' => (boolean) Whether to optimize the CSS output, e.g., combine rules.
85
-
* 'prettify' => (boolean) Whether to add new lines to output.
86
-
* );.
84
+
* @param array $options {
85
+
* Optional. An array of options. Default empty array.
86
+
*
87
+
* @type boolean $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
88
+
* @type boolean $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
* @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
280
-
* @param array $css_declarations An array of parsed CSS property => CSS value pairs.
278
+
* @param string $store_name A valid store key.
279
+
* @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
280
+
* @param array<string, string> $css_declarations An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
281
281
*
282
282
* @return void.
283
283
*/
@@ -308,15 +308,18 @@ public static function get_store( $store_name ) {
308
308
* @since 6.1.0
309
309
*
310
310
* @param array $block_styles The style object.
311
-
* @param array $options array(
312
-
* 'selector' => (string) When a selector is passed, `generate()` will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
313
-
* 'convert_vars_to_classnames' => (boolean) Whether to skip converting CSS var:? values to var( --wp--preset--* ) values. Default is `false`.
314
-
* );.
315
-
*
316
-
* @return array array(
317
-
* 'declarations' => (array) An array of parsed CSS property => CSS value pairs.
318
-
* 'classnames' => (array) A flat array of classnames.
319
-
* );
311
+
* @param array $options {
312
+
* Optional. An array of options. Default empty array.
313
+
*
314
+
* @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to var( --wp--preset--* ) values. Default `false`.
315
+
* @type string $selector Optional. When a selector is passed, the value of `$css` in the return value will comprise a full CSS rule `$selector { ...$css_declarations }`,
316
+
* otherwise, the value will be a concatenated string of CSS declarations.
317
+
* }
318
+
*
319
+
* @return array {
320
+
* @type string $classnames Classnames separated by a space.
321
+
* @type array<string, string> $declarations An array of property/value pairs representing parsed CSS declarations.
@@ -455,15 +460,17 @@ protected static function get_css_declarations( $style_value, $style_definition,
455
460
*
456
461
* @since 6.1.0
457
462
*
458
-
* @param array $style_value A single raw Gutenberg style attributes value for a CSS property.
459
-
* @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA.
460
-
* @param array $options array(
461
-
* 'convert_vars_to_classnames' => (boolean) Whether to skip converting CSS var:? values to var( --wp--preset--* ) values. Default is `false`.
462
-
* );.
463
+
* @param array $style_value A single raw style value from $block_styles array.
464
+
* @param array $individual_property_definition A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA representing an individual property of a CSS property, e.g., 'top' in 'border-top'.
465
+
* @param array $options {
466
+
* Optional. An array of options. Default empty array.
467
+
*
468
+
* @type bool $convert_vars_to_classnames Whether to skip converting incoming CSS var patterns, e.g., `var:preset|<PRESET_TYPE>|<PRESET_SLUG>`, to var( --wp--preset--* ) values. Default `false`.
@@ -502,8 +509,8 @@ protected static function get_individual_property_css_declarations( $style_value
502
509
*
503
510
* @since 6.1.0
504
511
*
505
-
* @param array $css_declarations An array of parsed CSS property => CSS value pairs.
506
-
* @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
512
+
* @param array<string, string> $css_declarations An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
513
+
* @param string $css_selector When a selector is passed, the function will return a full CSS rule `$selector { ...rules }`, otherwise a concatenated string of properties and values.
507
514
*
508
515
* @return string A compiled CSS string.
509
516
*/
@@ -528,10 +535,12 @@ public static function compile_css( $css_declarations, $css_selector ) {
528
535
* @since 6.1.0
529
536
*
530
537
* @param WP_Style_Engine_CSS_Rule[] $css_rules An array of WP_Style_Engine_CSS_Rule objects from a store or otherwise.
531
-
* @param array $options array(
532
-
* 'optimize' => (boolean) Whether to optimize the CSS output, e.g., combine rules.
533
-
* 'prettify' => (boolean) Whether to add new lines to output.
534
-
* );.
538
+
* @param array $options {
539
+
* Optional. An array of options. Default empty array.
540
+
*
541
+
* @type boolean $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`.
542
+
* @type boolean $prettify Whether to add new lines and indents to output. Default is the test of whether the global constant `SCRIPT_DEBUG` is defined.
543
+
* }
535
544
*
536
545
* @return string A compiled stylesheet from stored CSS rules.
0 commit comments