PluginProbe
Elementor Website Builder – more than just a page builder / 4.2.1
Elementor Website Builder – more than just a page builder v4.2.1
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 4.1.0-dev2 4.0.8 All 454 releases
← All changes | modules/atomic-widgets/css-converter/variable-prop-value-transformer.php +1 -66 4.3.0 → 4.2.1 View file →
@@ -4,16 +4,12 @@
4 4
5 5 use Elementor\Modules\AtomicWidgets\CssConverter\Converter_Registry_Factory;
6 6 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Array_Prop_Type;
7 7 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Object_Prop_Type;
8 -use Elementor\Modules\AtomicWidgets\PropTypes\Color_Prop_Type;
9 8 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
10 -use Elementor\Modules\AtomicWidgets\PropTypes\Font_Family_Prop_Type;
11 -use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
12 9 use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
13 10 use Elementor\Modules\AtomicWidgets\Styles\Size_Constants;
14 11 use Elementor\Modules\Variables\Adapters\Prop_Type_Adapter;
15 -use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type;
16 12 use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type;
17 13 use Elementor\Modules\Variables\Services\Variables_Service;
18 14 use Elementor\Modules\Variables\Utils\Variable_Type_Keys;
19 15
@@ -28,63 +24,8 @@
28 24 $this->variables_service = $variables_service;
29 25 }
30 26
31 27 /**
32 - * Resolves global-color-variable references inside gradient color stops to their actual color values.
33 - * Variables cannot be used inside gradient stops because the gradient UI control does not support them.
34 - * If a variable cannot be resolved, the entire background prop is ejected to custom CSS.
35 - *
36 - * @param array $props Mutated in place.
37 - * @param array<int, array{property: string, value: string, declaration: string}> $rules
38 - * @return string[] Extra custom CSS declarations produced by ejected props.
39 - */
40 - public function normalize_gradient_color_stops( array &$props, array $rules ): array {
41 - $background = $props['background'] ?? null;
42 -
43 - if ( ! is_array( $background ) || 'background' !== ( $background['$$type'] ?? null ) ) {
44 - return [];
45 - }
46 -
47 - $overlays = $background['value']['background-overlay']['value'] ?? null;
48 -
49 - if ( ! is_array( $overlays ) ) {
50 - return [];
51 - }
52 -
53 - foreach ( $overlays as $i => $overlay ) {
54 - if ( 'background-gradient-overlay' !== ( $overlay['$$type'] ?? null ) ) {
55 - continue;
56 - }
57 -
58 - $stops = $overlay['value']['stops']['value'] ?? [];
59 -
60 - foreach ( $stops as $j => $stop ) {
61 - if ( 'color-stop' !== ( $stop['$$type'] ?? null ) ) {
62 - continue;
63 - }
64 -
65 - $color = $stop['value']['color'] ?? null;
66 -
67 - if ( ! is_array( $color ) || Color_Variable_Prop_Type::get_key() !== ( $color['$$type'] ?? null ) ) {
68 - continue;
69 - }
70 -
71 - $variable = $this->variables_service->find_by_label_or_id( $color['value'] ?? '' );
72 -
73 - if ( null === $variable || '' === ( $variable['value'] ?? '' ) ) {
74 - unset( $props['background'] );
75 - $declaration = $this->declaration_for_ejected_prop( $rules, 'background' );
76 - return null !== $declaration ? [ $declaration . ';' ] : [];
77 - }
78 -
79 - $props['background']['value']['background-overlay']['value'][ $i ]['value']['stops']['value'][ $j ]['value']['color'] = Color_Prop_Type::generate( $variable['value'] );
80 - }
81 - }
82 -
83 - return [];
84 - }
85 -
86 - /**
87 28 * @param array $props
88 29 * @param array $schema
89 30 * @param array<int, array{property: string, value: string, declaration: string}> $rules
90 31 * @return array{props: array, custom_css: string[], rejected: string[]}
@@ -251,15 +192,9 @@
251 192 private function extract_var_reference( array $prop_value ): ?string {
252 193 $type = $prop_value['$$type'] ?? '';
253 194 $value = $prop_value['value'] ?? null;
254 195
255 - $string_backed_types = [
256 - Color_Prop_Type::get_key(),
257 - String_Prop_Type::get_key(),
258 - Font_Family_Prop_Type::get_key(),
259 - ];
260 -
261 - if ( in_array( $type, $string_backed_types, true ) && is_string( $value ) ) {
196 + if ( in_array( $type, [ 'color', 'string' ], true ) && is_string( $value ) ) {
262 197 return Css_Var_Reference::parse( $value );
263 198 }
264 199
265 200 if ( 'size' === $type && is_array( $value ) ) {