PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.3
Elementor Website Builder – more than just a page builder v4.3.3
4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 All 456 releases
← All changes | modules/mcp/abilities/appliers/style-applier.php +44 -1 4.3.2 → 4.3.3 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace Elementor\Modules\Mcp\Abilities\Appliers;
4 4
5 5 use Elementor\Modules\AtomicWidgets\CssConverter\Css_Converter;
6 +use Elementor\Modules\AtomicWidgets\Styles\Atomic_Widget_Styles;
6 7 use Elementor\Modules\Mcp\Abilities\Appliers\V3\V3_Style_Mapper_Factory;
7 8 use Elementor\Modules\Mcp\Abilities\Utils\Bulk_Operations_Result;
8 9 use Elementor\Modules\Mcp\Abilities\Utils\Style_Variants_Merger;
9 10 use Elementor\Modules\Mcp\Abilities\Utils\Widget_Context_Helper;
@@ -20,8 +21,10 @@
20 21 const DESKTOP_BREAKPOINT = 'desktop';
21 22 const LOCAL_STYLE_LABEL = 'local';
22 23 const LOCAL_STYLE_TYPE = 'class';
23 24
25 + const UNSUPPORTED_CSS_CODE = 'unsupported_css';
26 +
24 27 private Css_Converter $css_converter;
25 28 private array $active_breakpoints;
26 29
27 30 public function __construct( Css_Converter $css_converter, array $active_breakpoints = [] ) {
@@ -103,9 +106,25 @@
103 106 unset( $node );
104 107 continue;
105 108 }
106 109
107 - $new_variants = Style_Variants_Merger::build_variants( $parsed['breakpoint_blocks'], $this->css_converter );
110 + $built_variants = Style_Variants_Merger::build_variants_with_fallback_css( $parsed['breakpoint_blocks'], $this->css_converter );
111 + $new_variants = $built_variants['variants'];
112 + $unsupported_css = $this->collect_unsupported_css( $new_variants, $built_variants['fallback_css'] );
113 +
114 + if ( '' !== $unsupported_css ) {
115 + $warnings[] = sprintf(
116 + '[%s] %s',
117 + $config_id,
118 + sprintf(
119 + /* translators: %s: CSS declarations that were not saved */
120 + __( 'These CSS properties or values are not supported and were not saved: %s', 'elementor' ),
121 + self::truncate_css_snippet( $unsupported_css )
122 + )
123 + );
124 + $warning_codes[] = self::UNSUPPORTED_CSS_CODE;
125 + }
126 +
108 127 $affected_bps = array_column( $parsed['breakpoint_blocks'], 'breakpoint' );
109 128 $removal_bps = $parsed['removal_breakpoints'];
110 129 $existing_style_id = $this->find_existing_local_style_id( $node );
111 130 $existing_variants = $node['styles'][ $existing_style_id ]['variants'] ?? [];
@@ -220,8 +239,32 @@
220 239 return $css;
221 240 }
222 241
223 242 return substr( $css, 0, $max_length - 3 ) . '...';
243 + }
244 +
245 + /**
246 + * @param array[] $variants
247 + * @param array<int, string> $fallback_css Per variant index, CSS the converter could not convert natively.
248 + */
249 + private function collect_unsupported_css( array $variants, array $fallback_css ): string {
250 + if ( empty( $fallback_css ) ) {
251 + return '';
252 + }
253 +
254 + $kept_variants = Atomic_Widget_Styles::get_license_based_filtered_styles(
255 + [ self::LOCAL_STYLE_LABEL => [ 'variants' => array_intersect_key( $variants, $fallback_css ) ] ]
256 + )[ self::LOCAL_STYLE_LABEL ]['variants'];
257 +
258 + $dropped_css = [];
259 +
260 + foreach ( $fallback_css as $index => $css ) {
261 + if ( empty( $kept_variants[ $index ]['custom_css'] ) ) {
262 + $dropped_css[] = $css;
263 + }
264 + }
265 +
266 + return implode( ' ', $dropped_css );
224 267 }
225 268
226 269 private function get_active_breakpoints(): array {
227 270 if ( ! empty( $this->active_breakpoints ) ) {