← All changes
|
modules/atomic-widgets/styles/styles-renderer.php
+17
-3
4.1.2
→
3.34.0-beta1
View file →
| @@ -120,14 +120,16 @@ | ||
| 120 | 120 | if ( ! $css && ! $custom_css ) { |
| 121 | 121 | return ''; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | + $state = ''; | |
| 125 | + | |
| 124 | 126 | if ( isset( $variant['meta']['state'] ) ) { |
| 125 | - $selector = Style_States::get_selector_with_state( $base_selector, $variant['meta']['state'] ); | |
| 126 | - } else { | |
| 127 | - $selector = $base_selector; | |
| 127 | + $state = $this->get_state_with_selector( $variant['meta']['state'] ); | |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | + $selector = $base_selector . $state; | |
| 131 | + | |
| 130 | 132 | $style_declaration = $selector . '{' . $css . $custom_css . '}'; |
| 131 | 133 | |
| 132 | 134 | if ( isset( $variant['meta']['breakpoint'] ) ) { |
| 133 | 135 | $style_declaration = $this->wrap_with_media_query( $variant['meta']['breakpoint'], $style_declaration ); |
| @@ -133,8 +135,20 @@ | ||
| 133 | 135 | $style_declaration = $this->wrap_with_media_query( $variant['meta']['breakpoint'], $style_declaration ); |
| 134 | 136 | } |
| 135 | 137 | |
| 136 | 138 | return $style_declaration; |
| 139 | + } | |
| 140 | + | |
| 141 | + private function get_state_with_selector( string $state ): string { | |
| 142 | + if ( Style_States::is_class_state( $state ) ) { | |
| 143 | + return '.' . $state; | |
| 144 | + } | |
| 145 | + | |
| 146 | + if ( Style_States::is_pseudo_state( $state ) ) { | |
| 147 | + return ':' . $state; | |
| 148 | + } | |
| 149 | + | |
| 150 | + return ''; | |
| 137 | 151 | } |
| 138 | 152 | |
| 139 | 153 | |
| 140 | 154 | private function props_to_css_string( array $props ): string { |