PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-beta1
Elementor Website Builder – more than just a page builder v4.0.0-beta1
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/variables/services/variables-service.php +2 -39 4.2.1 → 4.0.0-beta1 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'] ) {
@@ -199,17 +166,13 @@
199 166 public function restore( string $id, $overrides = [] ) {
200 167 $collection = $this->repo->load();
201 168 $variable = $collection->find_or_fail( $id );
202 169
203 - $label = $variable->label();
170 + $collection->assert_limit_not_reached();
204 171
205 172 if ( isset( $overrides['label'] ) ) {
206 - $label = $overrides['label'];
173 + $collection->assert_label_is_unique( $overrides['label'], $variable->id() );
207 174 }
208 -
209 - $collection->assert_limit_not_reached();
210 -
211 - $collection->assert_label_is_unique( $label, $variable->id() );
212 175
213 176 $variable->apply_changes( $overrides );
214 177 $variable->validate();
215 178