← All changes
|
modules/atomic-widgets/styles/styles-renderer.php
+6
-8
4.1.0-dev2
→
3.32.0-dev3
View file →
| @@ -21,9 +21,9 @@ | ||
| 21 | 21 | private string $selector_prefix; |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * @param array<string, array{direction: 'min' | 'max', value: int, is_enabled: boolean}> $breakpoints |
| 25 | - * @param string $selector_prefix | |
| 25 | + * @param string $selector_prefix | |
| 26 | 26 | */ |
| 27 | 27 | private function __construct( array $breakpoints, string $selector_prefix = self::DEFAULT_SELECTOR_PREFIX ) { |
| 28 | 28 | $this->breakpoints = $breakpoints; |
| 29 | 29 | $this->selector_prefix = $selector_prefix; |
| @@ -120,13 +120,10 @@ | ||
| 120 | 120 | if ( ! $css && ! $custom_css ) { |
| 121 | 121 | return ''; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( isset( $variant['meta']['state'] ) ) { | |
| 125 | - $selector = Style_States::get_selector_with_state( $base_selector, $variant['meta']['state'] ); | |
| 126 | - } else { | |
| 127 | - $selector = $base_selector; | |
| 128 | - } | |
| 124 | + $state = isset( $variant['meta']['state'] ) ? ':' . $variant['meta']['state'] : ''; | |
| 125 | + $selector = $base_selector . $state; | |
| 129 | 126 | |
| 130 | 127 | $style_declaration = $selector . '{' . $css . $custom_css . '}'; |
| 131 | 128 | |
| 132 | 129 | if ( isset( $variant['meta']['breakpoint'] ) ) { |
| @@ -135,9 +132,8 @@ | ||
| 135 | 132 | |
| 136 | 133 | return $style_declaration; |
| 137 | 134 | } |
| 138 | 135 | |
| 139 | - | |
| 140 | 136 | private function props_to_css_string( array $props ): string { |
| 141 | 137 | $schema = Style_Schema::get(); |
| 142 | 138 | |
| 143 | 139 | return Collection::make( Render_Props_Resolver::for_styles()->resolve( $schema, $props ) ) |
| @@ -152,9 +148,11 @@ | ||
| 152 | 148 | ->implode( '' ); |
| 153 | 149 | } |
| 154 | 150 | |
| 155 | 151 | private function custom_css_to_css_string( ?array $custom_css ): string { |
| 156 | - return ! empty( $custom_css['raw'] ) | |
| 152 | + $is_feature_active = Plugin::$instance->experiments->is_feature_active( Module::EXPERIMENT_CUSTOM_CSS ); | |
| 153 | + | |
| 154 | + return $is_feature_active && ! empty( $custom_css['raw'] ) | |
| 157 | 155 | ? Utils::decode_string( $custom_css['raw'], '' ) . '\n' |
| 158 | 156 | : ''; |
| 159 | 157 | } |
| 160 | 158 | |