← All changes
|
modules/atomic-widgets/styles/atomic-styles-manager.php
+11
-18
4.3.0-beta3
→
3.35.8
View file →
| @@ -124,19 +124,17 @@ | ||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $breakpoint_path = array_merge( $path, [ $breakpoint_key ] ); |
| 127 | 127 | |
| 128 | - // `CSS_Files_Manager::get()` owns the per-breakpoint decision: it consults the | |
| 129 | - // cache-validity leaf under `$breakpoint_path` (including the `should_exist` | |
| 130 | - // meta), regenerates when the cache is invalid or when a should-be-present file | |
| 131 | - // is missing on disk, and validates the leaf on success. See ED-24903. | |
| 132 | 128 | $style_file = $this->css_files_manager->get( |
| 133 | 129 | $this->convert_path_to_handle( $breakpoint_path ), |
| 134 | 130 | $breakpoint_media, |
| 135 | 131 | $render_css, |
| 136 | - $breakpoint_path | |
| 132 | + $this->cache_validity->is_valid( $breakpoint_path ) | |
| 137 | 133 | ); |
| 138 | 134 | |
| 135 | + $this->cache_validity->validate( $breakpoint_path ); | |
| 136 | + | |
| 139 | 137 | if ( ! $style_file ) { |
| 140 | 138 | continue; |
| 141 | 139 | } |
| 142 | 140 | |
| @@ -155,10 +153,15 @@ | ||
| 155 | 153 | $style_fonts = Style_Fonts::make( $style_key ); |
| 156 | 154 | |
| 157 | 155 | return Styles_Renderer::make( |
| 158 | 156 | Plugin::$instance->breakpoints->get_breakpoints_config() |
| 159 | - )->on_font_enqueue( fn( $font ) => $style_fonts->add( $font ) ) | |
| 160 | - ->render( $styles ); | |
| 157 | + )->on_prop_transform( function( $key, $value ) use ( $style_fonts ) { | |
| 158 | + if ( 'font-family' !== $key ) { | |
| 159 | + return; | |
| 160 | + } | |
| 161 | + | |
| 162 | + $style_fonts->add( $value ); | |
| 163 | + } )->render( $styles ); | |
| 161 | 164 | } |
| 162 | 165 | |
| 163 | 166 | private function get_breakpoint_media( string $breakpoint_key ): ?string { |
| 164 | 167 | $breakpoint_config = Plugin::$instance->breakpoints->get_breakpoints_config()[ $breakpoint_key ] ?? null; |
| @@ -178,24 +181,14 @@ | ||
| 178 | 181 | return Collection::make( $styles )->reduce( function( $group, $style ) { |
| 179 | 182 | Collection::make( $style['variants'] )->each( function( $variant ) use ( &$group, $style ) { |
| 180 | 183 | $breakpoint = $variant['meta']['breakpoint'] ?? self::DEFAULT_BREAKPOINT; |
| 181 | 184 | |
| 182 | - if ( empty( $breakpoint ) ) { | |
| 183 | - $breakpoint = self::DEFAULT_BREAKPOINT; | |
| 184 | - } | |
| 185 | - | |
| 186 | 185 | if ( ! isset( $group[ $breakpoint ][ $style['id'] ] ) ) { |
| 187 | - $style_for_breakpoint = [ | |
| 186 | + $group[ $breakpoint ][ $style['id'] ] = [ | |
| 188 | 187 | 'id' => $style['id'], |
| 189 | 188 | 'type' => $style['type'], |
| 190 | 189 | 'variants' => [], |
| 191 | 190 | ]; |
| 192 | - | |
| 193 | - if ( isset( $style['cssName'] ) ) { | |
| 194 | - $style_for_breakpoint['cssName'] = $style['cssName']; | |
| 195 | - } | |
| 196 | - | |
| 197 | - $group[ $breakpoint ][ $style['id'] ] = $style_for_breakpoint; | |
| 198 | 191 | } |
| 199 | 192 | |
| 200 | 193 | $group[ $breakpoint ][ $style['id'] ]['variants'][] = $variant; |
| 201 | 194 | } ); |