← All changes
|
build/scripts/style-engine/class-wp-style-engine-processor-gutenberg.php
+17
-3
23.1.1
→
trunk
View file →
| @@ -96,9 +96,9 @@ | ||
| 96 | 96 | * Get the CSS rules as a string. |
| 97 | 97 | * |
| 98 | 98 | * Since 6.4.0 Optimization is no longer the default. |
| 99 | 99 | * |
| 100 | - * @param array $options { | |
| 100 | + * @param array $options { | |
| 101 | 101 | * Optional. An array of options. Default empty array. |
| 102 | 102 | * |
| 103 | 103 | * @type bool $optimize Whether to optimize the CSS output, e.g., combine rules. Default is `false`. |
| 104 | 104 | * @type bool $prettify Whether to add new lines and indents to output. Default is to inherit the value of the global constant `SCRIPT_DEBUG`, if it is defined. |
| @@ -141,11 +141,25 @@ | ||
| 141 | 141 | private function combine_rules_selectors() { |
| 142 | 142 | // Build an array of selectors along with the JSON-ified styles to make comparisons easier. |
| 143 | 143 | $selectors_json = array(); |
| 144 | 144 | foreach ( $this->css_rules as $rule ) { |
| 145 | - $declarations = $rule->get_declarations()->get_declarations(); | |
| 145 | + $declarations = $rule->get_declarations()->get_declarations(); | |
| 146 | + $declaration_options = $rule->get_declarations()->get_declaration_options(); | |
| 146 | 147 | ksort( $declarations ); |
| 147 | - $selectors_json[ $rule->get_selector() ] = wp_json_encode( $declarations ); | |
| 148 | + // Declaration options are keyed by property and are part of the rule identity. | |
| 149 | + ksort( $declaration_options ); | |
| 150 | + foreach ( $declaration_options as $property => $options ) { | |
| 151 | + if ( is_array( $options ) ) { | |
| 152 | + ksort( $options ); | |
| 153 | + $declaration_options[ $property ] = $options; | |
| 154 | + } | |
| 155 | + } | |
| 156 | + $selectors_json[ $rule->get_selector() ] = wp_json_encode( | |
| 157 | + array( | |
| 158 | + 'declarations' => $declarations, | |
| 159 | + 'declaration_options' => $declaration_options, | |
| 160 | + ) | |
| 161 | + ); | |
| 148 | 162 | } |
| 149 | 163 | |
| 150 | 164 | // Combine selectors that have the same styles. |
| 151 | 165 | foreach ( $selectors_json as $selector => $json ) { |