PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.9
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.9
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
← All changes | includes/Core/Importer/Runners/WPContent.php +43 -3 3.1.1 → 3.1.9 View file →
@@ -37,18 +37,34 @@
37 37 $path = $this->dir_path . 'wp-content' . DIRECTORY_SEPARATOR;
38 38 $post_types = $this->filter_post_types( $data['selected_post_types'] ?? [] );
39 39 $taxonomies = [];
40 40 $terms = [];
41 - $results = [];
41 + $results = [
42 + "wp-content" => $data["imported_data"]["wp-content"] ?? [],
43 + "terms" => $data["imported_data"]["terms"] ?? [],
44 + ];
42 45
43 46 $this->import_actions();
44 47
45 - $contents = $this->manifest['wp-content'];
48 + $contents = $imported_data['wp-content_manifest_content'] ?? $this->manifest['wp-content'];
49 + $this->processed = $imported_data['wp-content_processed'] ?? [];
46 50 $this->total = array_reduce( $contents, function ( $carry, $item ) {
47 51 return $carry + count( $item );
48 52 }, 0 );
49 53
54 + $processed_templates = $this->origin->get_progress();
55 +
56 + if(empty($processed_templates)){
57 + $this->log( 0 );
58 + $processed_templates = ["__started__"];
59 + $this->origin->update_progress( $processed_templates, ['wp-content_manifest_content' => $contents]);
60 + }
61 +
50 62 foreach ( $post_types as $type ) {
63 + if (in_array($type, $processed_templates)) {
64 + continue;
65 + }
66 +
51 67 if(empty($data['import_demo_content']) && !in_array($type, ['wp_navigation', 'nav_menu_item'])) {
52 68 continue;
53 69 }
54 70 $import = $this->import_type_data( $type, $path, $imported_data, $taxonomies, $terms );
@@ -55,11 +71,29 @@
55 71
56 72 if ( empty( $import['posts'] ) ) {
57 73 continue;
58 74 }
75 + if(isset($import['posts']['__attachments'])){
76 + $results['wp-content']['__attachments'][ $type ] = $import['posts']['__attachments'];
77 + unset($import['posts']['__attachments']);
78 + }
59 79 $results['wp-content'][ $type ] = $import['posts'];
60 80 $results['terms'][ $type ] = $import['terms'];
61 81 $imported_data = array_merge( $imported_data, $results );
82 +
83 + // Add the template to the processed templates and update the session data
84 + $processed_templates[] = $type;
85 + $this->origin->update_progress( $processed_templates, $results);
86 +
87 + // If it's not the last item, send the SSE message and exit
88 + if( end($post_types) !== $type) {
89 + $this->sse_message( [
90 + 'type' => 'continue',
91 + 'action' => 'continue',
92 + 'results' => __METHOD__ . '::' . __LINE__,
93 + ] );
94 + exit;
95 + }
62 96 }
63 97
64 98 $this->import_actions( true );
65 99
@@ -94,8 +128,10 @@
94 128
95 129 private function import_type_data( $type, $path, $imported_data, $taxonomies, $terms ): array {
96 130 $args = [
97 131 'fetch_attachments' => true,
132 + 'origin' => $this->origin,
133 + 'json' => $this->json,
98 134 'posts' => Utils::map_old_new_post_ids( $imported_data ),
99 135 'terms' => Utils::map_old_new_term_ids( $imported_data ),
100 136 'taxonomies' => ! empty( $taxonomies[ $type ] ) ? $taxonomies[ $type ] : [],
101 137 'posts_meta' => [
@@ -146,8 +182,10 @@
146 182 $this->processed[ $post['post_type'] ] = count($commonItems);
147 183
148 184 $type = $post['post_type'];
149 185 $title = $post['post_title'];
186 +
187 + $this->origin->update_progress( null, ['wp-content_processed' => $this->processed]);
150 188 } elseif ( isset( $post['term_id'] ) ) {
151 189 /**
152 190 * FIXME: We should fix it later, with a proper count of terms and make a total with post itself.
153 191 */
@@ -172,9 +210,10 @@
172 210 $this->log( $progress);
173 211 }
174 212
175 213 public function update_total( $WPImport ) {
176 - $contents = &$this->manifest['wp-content'];
214 + $session_data = $this->origin->get_session_data();
215 + $contents = $session_data['imported_data']['wp-content_manifest_content'];
177 216
178 217 foreach ($WPImport->posts as $key => $post) {
179 218 $postType = $post['post_type'];
180 219 $postId = $post['post_id'];
@@ -187,6 +226,7 @@
187 226 $this->total = array_reduce( $contents, function ( $carry, $item ) {
188 227 return $carry + count( $item );
189 228 }, 0 );
190 229
230 + $this->origin->update_progress( null, ['wp-content_manifest_content' => $contents]);
191 231 }
192 232 }