PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
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 4.1.0-dev2 All 455 releases
← All changes | modules/atomic-widgets/css-converter/converters/string-property-converter.php +17 -5 4.2.0 → 4.3.2 View file →
@@ -10,11 +10,14 @@
10 10 exit; // Exit if accessed directly.
11 11 }
12 12
13 13 /**
14 - * Reusable converter for properties backed by a plain String_Prop_Type. One instance per property.
15 - * When an allowlist is provided the value must be one of it (enum-backed props); otherwise any
16 - * non-empty value is accepted (free-string props). Emits the canonical PropValue from generate().
14 + * Reusable converter for properties backed by a String_Prop_Type (or a subclass with its own
15 + * `$$type` key, e.g. Font_Family_Prop_Type). One instance per property. When an allowlist is
16 + * provided the value must be one of it (enum-backed props); otherwise any non-empty value is
17 + * accepted (free-string props). Emits the canonical PropValue enveloped with the schema's own
18 + * `$$type` key, sourced from the live schema rather than hardcoded, so subclasses that override
19 + * get_key() (like Font_Family_Prop_Type) still validate against Props_Parser.
17 20 */
18 21 class String_Property_Converter extends Property_Converter_Base {
19 22 private string $property;
20 23
@@ -22,15 +25,21 @@
22 25 * @var string[]|null
23 26 */
24 27 private ?array $allowed_values;
25 28
29 + private string $type_key;
30 +
26 31 /**
27 32 * @param string $property The schema property this converter owns.
28 33 * @param string[]|null $allowed_values Enum allowlist, or null for a free-string property.
34 + * @param string|null $type_key The `$$type` key to envelope the value with, sourced from
35 + * the schema's prop type (e.g. `font-family`). Defaults to
36 + * the plain String_Prop_Type key.
29 37 */
30 - public function __construct( string $property, ?array $allowed_values = null ) {
38 + public function __construct( string $property, ?array $allowed_values = null, ?string $type_key = null ) {
31 39 $this->property = $property;
32 40 $this->allowed_values = $allowed_values;
41 + $this->type_key = $type_key ?? String_Prop_Type::get_key();
33 42 }
34 43
35 44 protected function get_supported_properties(): array {
36 45 return [ $this->property ];
@@ -46,9 +55,12 @@
46 55 if ( null !== $this->allowed_values && ! in_array( $value, $this->allowed_values, true ) ) {
47 56 return false;
48 57 }
49 58
50 - $context->set_prop( $this->property, String_Prop_Type::generate( $value ) );
59 + $context->set_prop( $this->property, [
60 + '$$type' => $this->type_key,
61 + 'value' => $value,
62 + ] );
51 63
52 64 return true;
53 65 }
54 66 }