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-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 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/variables/services/variables-service.php +2 -42 4.2.23.35.7 View file →
@@ -23,41 +23,8 @@
23 23 public function get_variables_list(): array {
24 24 return $this->load()['data'];
25 25 }
26 26
27 - public function find_by_label_or_id( string $needle ): ?array {
28 - $needle = trim( $needle );
29 - $needle = ltrim( $needle, '-' );
30 -
31 - if ( '' === $needle ) {
32 - return null;
33 - }
34 -
35 - $variables = $this->get_variables_list();
36 -
37 - if ( isset( $variables[ $needle ] ) ) {
38 - $variable = $variables[ $needle ];
39 -
40 - if ( ! empty( $variable['deleted'] ) ) {
41 - return null;
42 - }
43 -
44 - return array_merge( [ 'id' => $needle ], $variable );
45 - }
46 -
47 - foreach ( $variables as $id => $variable ) {
48 - if ( ! empty( $variable['deleted'] ) ) {
49 - continue;
50 - }
51 -
52 - if ( strcasecmp( $variable['label'] ?? '', $needle ) === 0 ) {
53 - return array_merge( [ 'id' => $id ], $variable );
54 - }
55 - }
56 -
57 - return null;
58 - }
59 -
60 27 public function load() {
61 28 $collection = $this->repo->load()->serialize( true );
62 29 foreach ( $collection['data'] as $id => $variable ) {
63 30 if ( ! ElementorUtils::has_pro() && Size_Variable_Prop_Type::get_key() === $variable['type'] ) {
@@ -126,9 +93,8 @@
126 93 $data['order'] = $collection->get_next_order();
127 94 }
128 95
129 96 $variable = Variable::from_array( $data );
130 - $variable->validate();
131 97
132 98 $collection->add_variable( $variable );
133 99
134 100 $watermark = $this->repo->save( $collection );
@@ -154,9 +120,8 @@
154 120 $collection->assert_label_is_unique( $data['label'], $id );
155 121 }
156 122
157 123 $variable->apply_changes( $data );
158 - $variable->validate();
159 124
160 125 $watermark = $this->repo->save( $collection );
161 126
162 127 if ( false === $watermark ) {
@@ -199,20 +164,15 @@
199 164 public function restore( string $id, $overrides = [] ) {
200 165 $collection = $this->repo->load();
201 166 $variable = $collection->find_or_fail( $id );
202 167
203 - $label = $variable->label();
168 + $collection->assert_limit_not_reached();
204 169
205 170 if ( isset( $overrides['label'] ) ) {
206 - $label = $overrides['label'];
171 + $collection->assert_label_is_unique( $overrides['label'], $variable->id() );
207 172 }
208 173
209 - $collection->assert_limit_not_reached();
210 -
211 - $collection->assert_label_is_unique( $label, $variable->id() );
212 -
213 174 $variable->apply_changes( $overrides );
214 - $variable->validate();
215 175
216 176 $variable->restore();
217 177
218 178 $watermark = $this->repo->save( $collection );