PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.7
Elementor Website Builder – more than just a page builder v3.35.7
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 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | modules/variables/storage/entities/variable.php +1 -31 4.3.0-beta23.35.7 View file →
@@ -4,9 +4,8 @@
4 4
5 5 use Elementor\Modules\Variables\Adapters\Prop_Type_Adapter;
6 6 use Elementor\Modules\Variables\PropTypes\Size_Variable_Prop_Type;
7 7 use Elementor\Modules\Variables\Storage\Exceptions\Type_Mismatch;
8 -use Elementor\Modules\Variables\Storage\Exceptions\InvalidVariable;
9 8 use InvalidArgumentException;
10 9
11 10 class Variable {
12 11 private array $data;
@@ -81,16 +80,8 @@
81 80 public function set_value( $value ) {
82 81 $this->data['value'] = $value;
83 82 }
84 83
85 - public function sync_to_v3(): bool {
86 - return ! empty( $this->data['sync_to_v3'] );
87 - }
88 -
89 - public function set_sync_to_v3( bool $sync_to_v3 ) {
90 - $this->data['sync_to_v3'] = $sync_to_v3;
91 - }
92 -
93 84 public function type() {
94 85 return $this->data['type'];
95 86 }
96 87
@@ -138,15 +129,10 @@
138 129
139 130 return true;
140 131 }
141 132
142 - /**
143 - * @throws InvalidVariable If the variable is not valid.
144 - */
145 133 public function apply_changes( array $data ): void {
146 - $this->validate();
147 -
148 - $allowed_fields = [ 'label', 'value', 'order', 'type', 'sync_to_v3' ];
134 + $allowed_fields = [ 'label', 'value', 'order', 'type' ];
149 135 $has_changes = $this->maybe_apply_type( $data );
150 136
151 137 foreach ( $allowed_fields as $field ) {
152 138 if ( isset( $data[ $field ] ) ) {
@@ -158,22 +144,6 @@
158 144
159 145 if ( $has_changes ) {
160 146 $this->data['updated_at'] = $this->now();
161 147 }
162 - }
163 -
164 - /**
165 - * @return bool True if the variable is valid, throws an exception otherwise.
166 - * @throws InvalidVariable If the variable is not valid.
167 - */
168 - public function validate(): bool {
169 - if ( strpos( $this->label(), ' ' ) !== false ) {
170 - throw new InvalidVariable( 'Label cannot contain spaces' );
171 - }
172 -
173 - if ( strlen( $this->label() ) > 50 ) {
174 - throw new InvalidVariable( 'Label cannot be longer than 50 characters' );
175 - }
176 -
177 - return true;
178 148 }
179 149 }