PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.8
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.8
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 3.1.10 All 111 releases
← All changes | includes/Core/Importer/Runners/Finalizer.php +70 -6 3.0.93.1.8 View file →
@@ -15,9 +15,8 @@
15 15 private $sub_type = '';
16 16 private $extra_content;
17 17
18 18 private $total_counts = 0;
19 - private $processed_items = 0;
20 19
21 20 /**
22 21 * @var array|mixed
23 22 */
@@ -61,9 +60,9 @@
61 60 if ( empty( $templates ) || ! is_array( $templates ) ) {
62 61 return;
63 62 }
64 63 foreach ( $templates as $id => $template ) {
65 - if ( ! isset( $template['data'] ) && !isset( $template['__attachments']) ) {
64 + if ( ! isset( $template['data'] ) && !isset( $template['__attachments']) && !isset($template['has_logo']) ) {
66 65 continue;
67 66 }
68 67
69 68 // if ( ! isset( $template['data']['form'] ) && ! isset( $template['data']['nav_menus'] )) {
@@ -89,19 +88,62 @@
89 88 if ( ! empty( $imported_data['extra-content'] ) ) {
90 89 $this->extra_content = $imported_data['extra-content'];
91 90 }
92 91
93 - $this->log( 0 );
94 92 add_action('templately_import.finalize_gutenberg_attachment', [$this, 'post_log'], 10, 2);
95 93
94 + // Get the processed templates from the session data
95 + $processed = $this->origin->get_progress();
96 +
97 + if(empty($processed)){
98 + $this->log( 0 );
99 + $processed = ["__started__"];
100 + $this->origin->update_progress( $processed);
101 + }
102 +
96 103 foreach ( $this->options as $type => $contents ) {
97 104 $this->type = $type;
105 +
106 + // If the template has been processed, skip it
107 + if (in_array($type, $processed)) {
108 + continue;
109 + }
110 +
98 111 if ( $type == 'templates' ) {
99 112 $this->finalize_imports( $contents );
113 +
114 + $processed[] = $type;
115 + $this->origin->update_progress( $processed);
116 + // If it's not the last item, send the SSE message and exit
117 + if( end($this->options) !== $contents ) {
118 + $this->sse_message( [
119 + 'type' => 'continue',
120 + 'action' => 'continue',
121 + 'results' => __METHOD__ . '::' . __LINE__,
122 + ] );
123 + exit;
124 + }
100 125 } else {
101 126 foreach ( $contents as $post_type => $templates ) {
127 + // If the template has been processed, skip it
128 + if (in_array("$type::$post_type", $processed)) {
129 + continue;
130 + }
131 +
102 132 $this->sub_type = $post_type;
103 133 $this->finalize_imports( $templates );
134 +
135 + $processed[] = "$type::$post_type";
136 + $this->origin->update_progress( $processed);
137 + // If it's not the last item, send the SSE message and exit
138 + if( end($contents) !== $templates ) {
139 + $this->sse_message( [
140 + 'type' => 'continue',
141 + 'action' => 'continue',
142 + 'results' => __METHOD__ . '::' . __LINE__,
143 + ] );
144 + exit;
145 + }
104 146 }
105 147 }
106 148 }
107 149
@@ -120,9 +162,17 @@
120 162 }
121 163 }
122 164
123 165 private function finalize_imports( $templates ) {
166 + // Get the processed templates from the session data
167 + $processed = $this->origin->get_progress();
168 +
124 169 foreach ( $templates as $old_template_id => $template_settings ) {
170 + // If the template has been processed, skip it
171 + if (in_array($old_template_id, $processed)) {
172 + continue;
173 + }
174 +
125 175 try {
126 176 $path = $this->dir_path . $this->type . DIRECTORY_SEPARATOR;
127 177 if ( ! empty( $this->sub_type ) ) {
128 178 $path .= $this->sub_type . DIRECTORY_SEPARATOR;
@@ -128,16 +178,30 @@
128 178 $path .= $this->sub_type . DIRECTORY_SEPARATOR;
129 179 }
130 180 $path .= "{$old_template_id}.json";
131 181 $template_json = Utils::read_json_file( $path );
132 - $this->json->prepare( $template_json, $template_settings, $this->extra_content['form'][ $old_template_id ] ?? [] )->update();
182 + $params = $this->origin->get_request_params();
183 + $this->json->prepare( $template_json, $template_settings, $this->extra_content['form'][ $old_template_id ] ?? [], $params )->update();
133 184
134 185 // Broadcast Log
135 - $this->processed_items += 1;
136 - $progress = floor( ( 100 * $this->processed_items ) / $this->total_counts );
186 + $progress = floor( ( 100 * count($processed) ) / $this->total_counts );
137 187 $this->log( $progress );
138 188 } catch ( Exception $e ) {
139 189 continue;
190 + }
191 +
192 + // Add the template to the processed templates and update the session data
193 + $processed[] = $old_template_id;
194 + $this->origin->update_progress( $processed);
195 +
196 + // If it's not the last item, send the SSE message and exit
197 + if( end($templates) !== $template_settings) {
198 + $this->sse_message( [
199 + 'type' => 'continue',
200 + 'action' => 'continue',
201 + 'results' => __METHOD__ . '::' . __LINE__,
202 + ] );
203 + exit;
140 204 }
141 205 }
142 206 }
143 207