PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-dev4
Elementor Website Builder – more than just a page builder v4.0.0-dev4
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 | core/utils/template-library-snapshot-processor.php +6 -27 4.2.44.0.0-dev4 View file →
@@ -14,17 +14,9 @@
14 14 abstract protected function load_current_data(): array;
15 15 abstract protected function parse_incoming_snapshot( array $snapshot ): ?array;
16 16 abstract protected function get_incoming_items( array $parsed_snapshot ): array;
17 17 abstract protected function count_current_items( array $items ): int;
18 - /**
19 - * @param array $data {
20 - * @type array $updated_items All items (existing + new) after processing.
21 - * @type array $new_items Only the newly added items.
22 - * @type array $order The updated order of all items.
23 - * }
24 - * @param array $metadata The original data from load_current_data().
25 - */
26 - abstract protected function save_data( array $data, array $metadata ): array;
18 + abstract protected function save_data( array $items, array $metadata ): array;
27 19
28 20 protected function normalize_for_comparison( array $item ): array {
29 21 return $item;
30 22 }
@@ -60,9 +52,8 @@
60 52 $label_to_id = Template_Library_Import_Export_Utils::build_label_to_id_index( $current_items );
61 53
62 54 $id_map = [];
63 55 $ids_to_flatten = [];
64 - $new_items = [];
65 56 $updated_items = $current_items;
66 57 $existing_ids = array_fill_keys( array_keys( $updated_items ), true );
67 58 $updated_order = $current['order'] ?? [];
68 59
@@ -114,10 +105,9 @@
114 105 $target_id,
115 106 $updated_items,
116 107 $existing_ids,
117 108 $existing_labels,
118 - $updated_order,
119 - $new_items
109 + $updated_order
120 110 );
121 111
122 112 $new_label = $updated_items[ $target_id ]['label'] ?? null;
123 113 if ( is_string( $new_label ) && ! isset( $label_to_id[ $new_label ] ) ) {
@@ -124,13 +114,9 @@
124 114 $label_to_id[ $new_label ] = $target_id;
125 115 }
126 116 }
127 117
128 - $saved_result = $this->save_data( [
129 - 'updated_items' => $updated_items,
130 - 'new_items' => $new_items,
131 - 'order' => $updated_order,
132 - ], $current );
118 + $saved_result = $this->save_data( $updated_items, array_merge( $current, [ 'order' => $updated_order ] ) );
133 119
134 120 return array_merge($this->get_empty_result(), [
135 121 'id_map' => $id_map,
136 122 'ids_to_flatten' => $ids_to_flatten,
@@ -158,9 +144,8 @@
158 144 $existing_labels = Template_Library_Import_Export_Utils::extract_labels( $current_items );
159 145
160 146 $id_map = [];
161 147 $ids_to_flatten = [];
162 - $new_items = [];
163 148 $updated_items = $current_items;
164 149 $existing_ids = array_fill_keys( array_keys( $updated_items ), true );
165 150 $updated_order = $current['order'] ?? [];
166 151
@@ -191,18 +176,13 @@
191 176 $target_id,
192 177 $updated_items,
193 178 $existing_ids,
194 179 $existing_labels,
195 - $updated_order,
196 - $new_items
180 + $updated_order
197 181 );
198 182 }
199 183
200 - $saved_result = $this->save_data( [
201 - 'updated_items' => $updated_items,
202 - 'new_items' => $new_items,
203 - 'order' => $updated_order,
204 - ], $current );
184 + $saved_result = $this->save_data( $updated_items, array_merge( $current, [ 'order' => $updated_order ] ) );
205 185
206 186 return array_merge($this->get_empty_result(), [
207 187 'id_map' => $id_map,
208 188 'ids_to_flatten' => $ids_to_flatten,
@@ -208,13 +188,12 @@
208 188 'ids_to_flatten' => $ids_to_flatten,
209 189 ], $saved_result);
210 190 }
211 191
212 - protected function add_item_with_label( array $item, string $target_id, array &$updated_items, array &$existing_ids, array &$existing_labels, array &$updated_order, array &$new_items ): void {
192 + protected function add_item_with_label( array $item, string $target_id, array &$updated_items, array &$existing_ids, array &$existing_labels, array &$updated_order ): void {
213 193 $item = $this->prepare_item_for_save( $item, $target_id );
214 194 $item = Template_Library_Import_Export_Utils::apply_unique_label( $item, $existing_labels );
215 195 $updated_items[ $target_id ] = $item;
216 - $new_items[ $target_id ] = $item;
217 196 $existing_ids[ $target_id ] = true;
218 197
219 198 if ( ! in_array( $target_id, $updated_order, true ) ) {
220 199 $updated_order[] = $target_id;