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