| @@ -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; |
| @@ -130,15 +129,10 @@ | ||
| 130 | 129 | |
| 131 | 130 | return true; |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | - /** | |
| 135 | - * @throws InvalidVariable If the variable is not valid. | |
| 136 | - */ | |
| 137 | 133 | public function apply_changes( array $data ): void { |
| 138 | - $this->validate(); | |
| 139 | - | |
| 140 | - $allowed_fields = [ 'label', 'value', 'order', 'type', 'sync_to_v3' ]; | |
| 134 | + $allowed_fields = [ 'label', 'value', 'order', 'type' ]; | |
| 141 | 135 | $has_changes = $this->maybe_apply_type( $data ); |
| 142 | 136 | |
| 143 | 137 | foreach ( $allowed_fields as $field ) { |
| 144 | 138 | if ( isset( $data[ $field ] ) ) { |
| @@ -150,22 +144,6 @@ | ||
| 150 | 144 | |
| 151 | 145 | if ( $has_changes ) { |
| 152 | 146 | $this->data['updated_at'] = $this->now(); |
| 153 | 147 | } |
| 154 | - } | |
| 155 | - | |
| 156 | - /** | |
| 157 | - * @return bool True if the variable is valid, throws an exception otherwise. | |
| 158 | - * @throws InvalidVariable If the variable is not valid. | |
| 159 | - */ | |
| 160 | - public function validate(): bool { | |
| 161 | - if ( strpos( $this->label(), ' ' ) !== false ) { | |
| 162 | - throw new InvalidVariable( 'Label cannot contain spaces' ); | |
| 163 | - } | |
| 164 | - | |
| 165 | - if ( strlen( $this->label() ) > 50 ) { | |
| 166 | - throw new InvalidVariable( 'Label cannot be longer than 50 characters' ); | |
| 167 | - } | |
| 168 | - | |
| 169 | - return true; | |
| 170 | 148 | } |
| 171 | 149 | } |