PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.1
Elementor Website Builder – more than just a page builder v3.13.1
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 4.0.7 All 451 releases
elementor / app / modules / import-export / processes / import.php

import.php in Elementor Website Builder – more than just a page builder 3.13.1, at app/modules/import-export/processes/import.php

777 lines 23.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\App\Modules\ImportExport\Processes;
4
5 use Elementor\App\Modules\ImportExport\Compatibility\Base_Adapter;
6 use Elementor\App\Modules\ImportExport\Compatibility\Envato;
7 use Elementor\App\Modules\ImportExport\Compatibility\Kit_Library;
8 use Elementor\App\Modules\ImportExport\Utils;
9 use Elementor\Core\Base\Document;
10 use Elementor\Core\Kits\Documents\Kit;
11 use Elementor\Plugin;
12
13 use Elementor\App\Modules\ImportExport\Runners\Import\Elementor_Content;
14 use Elementor\App\Modules\ImportExport\Runners\Import\Import_Runner_Base;
15 use Elementor\App\Modules\ImportExport\Runners\Import\Plugins;
16 use Elementor\App\Modules\ImportExport\Runners\Import\Site_Settings;
17 use Elementor\App\Modules\ImportExport\Runners\Import\Taxonomies;
18 use Elementor\App\Modules\ImportExport\Runners\Import\Templates;
19 use Elementor\App\Modules\ImportExport\Runners\Import\Wp_Content;
20 use Elementor\App\Modules\ImportExport\Module;
21 use Elementor\App\Modules\KitLibrary\Connect\Kit_Library as Kit_Library_Api;
22
23 class Import {
24 const MANIFEST_ERROR_KEY = 'manifest-error';
25
26 const ZIP_FILE_ERROR_KEY = 'zip-file-error';
27
28 /**
29 * @var Import_Runner_Base[]
30 */
31 protected $runners = [];
32
33 /**
34 * The session ID of the import process.
35 * This ID is uniquely generated for each import process (by the temp folder which contains the extracted kit files).
36 *
37 * @var string
38 */
39 private $session_id;
40
41 /**
42 * The Kit ID.
43 *
44 * @var string
45 */
46 private $kit_id;
47
48 /**
49 * Adapter for the kit compatibility.
50 *
51 * @var Base_Adapter[]
52 */
53 private $adapters;
54
55 /**
56 * Document's data (elements and settings) that was imported during the process.
57 *
58 * @var array { [document_id] => { "elements": array , "settings": array } }
59 */
60 private $documents_data = [];
61
62 /**
63 * Path to the extracted kit files.
64 *
65 * @var string
66 */
67 private $extracted_directory_path;
68
69 /**
70 * Imported kit manifest.
71 *
72 * @var array
73 */
74 private $manifest;
75
76 /**
77 * Imported kit site settings. (e.g: custom_colors, custom_typography, etc.)
78 *
79 * @var array
80 */
81 private $site_settings;
82
83 /**
84 * Selected content types to import.
85 *
86 * @var array
87 */
88 private $settings_include;
89
90 /**
91 * Referer of the import. (e.g: kit-library, local, etc.)
92 *
93 * @var string
94 */
95 private $settings_referrer;
96
97 /**
98 * All the conflict between the exited templates and the kit templates.
99 *
100 * @var array
101 */
102 private $settings_conflicts;
103
104 /**
105 * Selected elementor templates conditions to override.
106 *
107 * @var array
108 */
109 private $settings_selected_override_conditions;
110
111 /**
112 * Selected custom post types to import.
113 *
114 * @var array
115 */
116 private $settings_selected_custom_post_types;
117
118 /**
119 * Selected plugins to import.
120 *
121 * @var array
122 */
123 private $settings_selected_plugins;
124
125 /**
126 * The imported data output.
127 *
128 * @var array
129 */
130 private $imported_data = [];
131
132 /**
133 * The metadata output of the import runners.
134 * Will be saved in the import_session and will be used to revert the import process.
135 *
136 * @var array
137 */
138 private $runners_import_metadata = [];
139
140 /**
141 * @param string $path session_id | zip_file_path
142 * @param array $settings Use to determine which content to import.
143 * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
144 * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance.
145 * We are using it for quick creation of the instance when the import process is being split into chunks.
146 * @throws \Exception
147 */
148 public function __construct( string $path, array $settings = [], array $old_instance = null ) {
149 if ( ! empty( $old_instance ) ) {
150 $this->set_import_object( $old_instance );
151 } else {
152 if ( is_file( $path ) ) {
153 $this->extracted_directory_path = $this->extract_zip( $path );
154 } else {
155 $elementor_tmp_directory = Plugin::$instance->uploads_manager->get_temp_dir();
156 $path = $elementor_tmp_directory . basename( $path );
157
158 if ( ! is_dir( $path ) ) {
159 throw new \Exception( 'Couldn’t execute the import process because the import session does not exist.' );
160 }
161
162 $this->extracted_directory_path = $path . '/';
163 }
164
165 $this->session_id = basename( $this->extracted_directory_path );
166 $this->kit_id = $settings['id'] ?? '';
167 $this->settings_referrer = ! empty( $settings['referrer'] ) ? $settings['referrer'] : 'local';
168 $this->settings_include = ! empty( $settings['include'] ) ? $settings['include'] : null;
169
170 // Using isset and not empty is important since empty array is valid option.
171 $this->settings_selected_override_conditions = $settings['overrideConditions'] ?? null;
172 $this->settings_selected_custom_post_types = $settings['selectedCustomPostTypes'] ?? null;
173 $this->settings_selected_plugins = $settings['plugins'] ?? null;
174
175 $this->manifest = $this->read_manifest_json();
176 $this->site_settings = $this->read_site_settings_json();
177
178 $this->set_default_settings();
179 }
180 }
181
182 /**
183 * Set the import object parameters.
184 *
185 * @param array $instance
186 * @return void
187 */
188 private function set_import_object( array $instance ) {
189 $this->session_id = $instance['session_id'];
190
191 $instance_data = $instance['instance_data'];
192
193 $this->extracted_directory_path = $instance_data['extracted_directory_path'];
194 $this->runners = $instance_data['runners'];
195 $this->adapters = $instance_data['adapters'];
196
197 $this->manifest = $instance_data['manifest'];
198 $this->site_settings = $instance_data['site_settings'];
199
200 $this->settings_include = $instance_data['settings_include'];
201 $this->settings_referrer = $instance_data['settings_referrer'];
202 $this->settings_conflicts = $instance_data['settings_conflicts'];
203 $this->settings_selected_override_conditions = $instance_data['settings_selected_override_conditions'];
204 $this->settings_selected_custom_post_types = $instance_data['settings_selected_custom_post_types'];
205 $this->settings_selected_plugins = $instance_data['settings_selected_plugins'];
206
207 $this->documents_data = $instance_data['documents_data'];
208 $this->imported_data = $instance_data['imported_data'];
209 $this->runners_import_metadata = $instance_data['runners_import_metadata'];
210 }
211
212 /**
213 * Creating a new instance of the import process by the id of the old import session.
214 *
215 * @param string $session_id
216 *
217 * @return Import
218 * @throws \Exception
219 */
220 public static function from_session( string $session_id ): Import {
221 $import_sessions = get_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS );
222
223 if ( ! $import_sessions || ! isset( $import_sessions[ $session_id ] ) ) {
224 throw new \Exception( 'Couldn’t execute the import process because the import session does not exist.' );
225 }
226
227 $import_session = $import_sessions[ $session_id ];
228
229 return new self( $session_id, [], $import_session );
230 }
231
232 /**
233 * Register a runner.
234 * Be aware that the runner will be executed in the order of registration, the order is crucial for the import process.
235 *
236 * @param Import_Runner_Base $runner_instance
237 */
238 public function register( Import_Runner_Base $runner_instance ) {
239 $this->runners[ $runner_instance::get_name() ] = $runner_instance;
240 }
241
242 public function register_default_runners() {
243 $this->register( new Site_Settings() );
244 $this->register( new Plugins() );
245 $this->register( new Templates() );
246 $this->register( new Taxonomies() );
247 $this->register( new Elementor_Content() );
248 $this->register( new Wp_Content() );
249 }
250
251 /**
252 * Set default settings for the import.
253 */
254 private function set_default_settings() {
255 if ( ! is_array( $this->get_settings_include() ) ) {
256 $this->settings_include( $this->get_default_settings_include() );
257 }
258
259 if ( ! is_array( $this->get_settings_conflicts() ) ) {
260 $this->settings_conflicts( $this->get_default_settings_conflicts() );
261 }
262
263 if ( ! is_array( $this->get_settings_selected_override_conditions() ) ) {
264 $this->settings_selected_override_conditions( $this->get_default_settings_override_conditions() );
265 }
266
267 if ( ! is_array( $this->get_settings_selected_custom_post_types() ) ) {
268 $this->settings_selected_custom_post_types( $this->get_default_settings_custom_post_types() );
269 }
270
271 if ( ! is_array( $this->get_settings_selected_plugins() ) ) {
272 $this->settings_selected_plugins( $this->get_default_settings_plugins() );
273 }
274 }
275
276 /**
277 * Execute the import process.
278 *
279 * @return array The imported data output.
280 *
281 * @throws \Exception If no import runners have been specified.
282 */
283 public function run() {
284 if ( empty( $this->runners ) ) {
285 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
286 }
287
288 $data = [
289 'session_id' => $this->session_id,
290 'include' => $this->settings_include,
291 'manifest' => $this->manifest,
292 'site_settings' => $this->site_settings,
293 'selected_plugins' => $this->settings_selected_plugins,
294 'extracted_directory_path' => $this->extracted_directory_path,
295 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
296 ];
297
298 $this->init_import_session();
299
300 add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 );
301
302 // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads.
303 Plugin::$instance->uploads_manager->set_elementor_upload_state( true );
304
305 foreach ( $this->runners as $runner ) {
306 if ( $runner->should_import( $data ) ) {
307 $import = $runner->import( $data, $this->imported_data );
308 $this->imported_data = array_merge_recursive( $this->imported_data, $import );
309
310 $this->runners_import_metadata[ $runner::get_name() ] = $runner->get_import_session_metadata();
311 }
312 }
313
314 // After the upload complete, set the elementor upload state back to false.
315 Plugin::$instance->uploads_manager->set_elementor_upload_state( false );
316
317 remove_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10 );
318
319 $this->finalize_import_session_option();
320
321 $this->save_elements_of_imported_posts();
322
323 Plugin::$instance->uploads_manager->remove_file_or_dir( $this->extracted_directory_path );
324 return $this->imported_data;
325 }
326
327 /**
328 * Run specific runner by runner_name
329 *
330 * @param string $runner_name
331 *
332 * @return array
333 *
334 * @throws \Exception If no export runners have been specified.
335 */
336 public function run_runner( string $runner_name ): array {
337 if ( empty( $this->runners ) ) {
338 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
339 }
340
341 $data = [
342 'session_id' => $this->session_id,
343 'include' => $this->settings_include,
344 'manifest' => $this->manifest,
345 'site_settings' => $this->site_settings,
346 'selected_plugins' => $this->settings_selected_plugins,
347 'extracted_directory_path' => $this->extracted_directory_path,
348 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
349 ];
350
351 add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 );
352
353 // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads.
354 Plugin::$instance->uploads_manager->set_elementor_upload_state( true );
355
356 $runner = $this->runners[ $runner_name ];
357
358 if ( empty( $runner ) ) {
359 throw new \Exception( 'Couldn’t execute the import process because the import runner was not found. Try again by specifying an import runner.' );
360 }
361
362 if ( $runner->should_import( $data ) ) {
363 $import = $runner->import( $data, $this->imported_data );
364 $this->imported_data = array_merge_recursive( $this->imported_data, $import );
365
366 $this->runners_import_metadata[ $runner::get_name() ] = $runner->get_import_session_metadata();
367 }
368
369 // After the upload complete, set the elementor upload state back to false.
370 Plugin::$instance->uploads_manager->set_elementor_upload_state( false );
371
372 remove_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10 );
373
374 $is_last_runner = key( array_slice( $this->runners, -1, 1, true ) ) === $runner_name;
375 if ( $is_last_runner ) {
376 $this->finalize_import_session_option();
377 $this->save_elements_of_imported_posts();
378 } else {
379 $this->update_instance_data_in_import_session_option();
380 }
381
382 return [
383 'status' => 'success',
384 'runner' => $runner_name,
385 ];
386 }
387
388 /**
389 * Create and save all the instance data to the import sessions option.
390 *
391 * @return void
392 */
393 public function init_import_session( $save_instance_data = false ) {
394 $import_sessions = get_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS );
395
396 $import_sessions[ $this->session_id ] = [
397 'session_id' => $this->session_id,
398 'kit_title' => $this->manifest['title'] ?? '',
399 'kit_name' => $this->manifest['name'] ?? '',
400 'kit_thumbnail' => $this->get_kit_thumbnail(),
401 'kit_source' => $this->settings_referrer,
402 'user_id' => get_current_user_id(),
403 'start_timestamp' => current_time( 'timestamp' ),
404 ];
405
406 if ( $save_instance_data ) {
407 $import_sessions[ $this->session_id ]['instance_data'] = [
408 'extracted_directory_path' => $this->extracted_directory_path,
409 'runners' => $this->runners,
410 'adapters' => $this->adapters,
411
412 'manifest' => $this->manifest,
413 'site_settings' => $this->site_settings,
414
415 'settings_include' => $this->settings_include,
416 'settings_referrer' => $this->settings_referrer,
417 'settings_conflicts' => $this->settings_conflicts,
418 'settings_selected_override_conditions' => $this->settings_selected_override_conditions,
419 'settings_selected_custom_post_types' => $this->settings_selected_custom_post_types,
420 'settings_selected_plugins' => $this->settings_selected_plugins,
421
422 'documents_data' => $this->documents_data,
423 'imported_data' => $this->imported_data,
424 'runners_import_metadata' => $this->runners_import_metadata,
425 ];
426 }
427
428 update_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS, $import_sessions, false );
429 }
430
431 /**
432 * Get the Kit thumbnail, goes to the home page thumbnail if main doesn't exist
433 *
434 * @return string
435 */
436 private function get_kit_thumbnail(): string {
437 if ( ! empty( $this->manifest['thumbnail'] ) ) {
438 return $this->manifest['thumbnail'];
439 }
440
441 if ( empty( $this->kit_id ) ) {
442 return '';
443 }
444
445 $api = new Kit_Library_Api();
446 $kit = $api->get_by_id( $this->kit_id );
447
448 if ( is_wp_error( $kit ) ) {
449 return '';
450 }
451
452 return $kit->thumbnail;
453 }
454
455 public function get_runners_name(): array {
456 return array_keys( $this->runners );
457 }
458
459 public function get_manifest() {
460 return $this->manifest;
461 }
462
463 public function get_extracted_directory_path() {
464 return $this->extracted_directory_path;
465 }
466
467 public function get_session_id() {
468 return $this->session_id;
469 }
470
471 public function get_adapters() {
472 return $this->adapters;
473 }
474
475 public function get_imported_data() {
476 return $this->imported_data;
477 }
478
479 /**
480 * Get settings by key.
481 * Used for backward compatibility.
482 *
483 * @param string $key The key of the setting.
484 */
485 public function get_settings( $key ) {
486 switch ( $key ) {
487 case 'include':
488 return $this->get_settings_include();
489
490 case 'overrideConditions':
491 return $this->get_settings_selected_override_conditions();
492
493 case 'selectedCustomPostTypes':
494 return $this->get_settings_selected_custom_post_types();
495
496 case 'plugins':
497 return $this->get_settings_selected_plugins();
498
499 default:
500 return [];
501 }
502 }
503
504 public function settings_include( array $settings_include ) {
505 $this->settings_include = $settings_include;
506
507 return $this;
508 }
509
510 public function get_settings_include() {
511 return $this->settings_include;
512 }
513
514 public function settings_referrer( $settings_referrer ) {
515 $this->settings_referrer = $settings_referrer;
516
517 return $this;
518 }
519
520 public function get_settings_referrer() {
521 return $this->settings_referrer;
522 }
523
524 public function settings_conflicts( array $settings_conflicts ) {
525 $this->settings_conflicts = $settings_conflicts;
526
527 return $this;
528 }
529
530 public function get_settings_conflicts() {
531 return $this->settings_conflicts;
532 }
533
534 public function settings_selected_override_conditions( array $settings_selected_override_conditions ) {
535 $this->settings_selected_override_conditions = $settings_selected_override_conditions;
536
537 return $this;
538 }
539
540 public function get_settings_selected_override_conditions() {
541 return $this->settings_selected_override_conditions;
542 }
543
544 public function settings_selected_custom_post_types( array $settings_selected_custom_post_types ) {
545 $this->settings_selected_custom_post_types = $settings_selected_custom_post_types;
546
547 return $this;
548 }
549
550 public function get_settings_selected_custom_post_types() {
551 return $this->settings_selected_custom_post_types;
552 }
553
554 public function settings_selected_plugins( array $settings_selected_plugins ) {
555 $this->settings_selected_plugins = $settings_selected_plugins;
556
557 return $this;
558 }
559
560 public function get_settings_selected_plugins() {
561 return $this->settings_selected_plugins;
562 }
563
564 /**
565 * Prevent saving elements on elementor post creation.
566 *
567 * @param array $data
568 * @param Document $document
569 *
570 * @return array
571 */
572 public function prevent_saving_elements_on_post_creation( array $data, Document $document ) {
573 if ( isset( $data['elements'] ) ) {
574 $this->documents_data[ $document->get_main_id() ] = [ 'elements' => $data['elements'] ];
575
576 $data['elements'] = [];
577 }
578
579 if ( isset( $data['settings'] ) ) {
580 $this->documents_data[ $document->get_main_id() ]['settings'] = $data['settings'];
581
582 }
583
584 return $data;
585 }
586
587 /**
588 * Extract the zip file.
589 *
590 * @param string $zip_path The path to the zip file.
591 * @return string The extracted directory path.
592 */
593 private function extract_zip( $zip_path ) {
594 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
595
596 if ( is_wp_error( $extraction_result ) ) {
597 throw new \Error( static::ZIP_FILE_ERROR_KEY );
598 }
599
600 return $extraction_result['extraction_directory'];
601 }
602
603 /**
604 * Get the manifest file from the extracted directory and adapt it if needed.
605 *
606 * @return string The manifest file content.
607 */
608 private function read_manifest_json() {
609 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
610
611 if ( ! $manifest ) {
612 throw new \Error( static::MANIFEST_ERROR_KEY );
613 }
614
615 $this->init_adapters( $manifest );
616
617 foreach ( $this->adapters as $adapter ) {
618 $manifest = $adapter->adapt_manifest( $manifest );
619 }
620
621 return $manifest;
622 }
623
624 /**
625 * Init the adapters and determine which ones to use.
626 *
627 * @param array $manifest_data The manifest file content.
628 */
629 private function init_adapters( array $manifest_data ) {
630 $this->adapters = [];
631
632 /** @var Base_Adapter[] $adapter_types */
633 $adapter_types = [ Envato::class, Kit_Library::class ];
634
635 foreach ( $adapter_types as $adapter_type ) {
636 if ( $adapter_type::is_compatibility_needed( $manifest_data, [ 'referrer' => $this->get_settings_referrer() ] ) ) {
637 $this->adapters[] = new $adapter_type( $this );
638 }
639 }
640 }
641
642 /**
643 * Get the site settings file from the extracted directory and adapt it if needed.
644 *
645 * @return string The site settings file content.
646 */
647 private function read_site_settings_json() {
648 $site_settings = Utils::read_json_file( $this->extracted_directory_path . 'site-settings' );
649
650 foreach ( $this->adapters as $adapter ) {
651 $site_settings = $adapter->adapt_site_settings( $site_settings, $this->manifest, $this->extracted_directory_path );
652 }
653
654 return $site_settings;
655 }
656
657 /**
658 * Get all the custom post types in the kit.
659 *
660 * @return array Custom post types names.
661 */
662 private function get_default_settings_custom_post_types() {
663 if ( empty( $this->manifest['custom-post-type-title'] ) ) {
664 return [];
665 }
666
667 $manifest_post_types = array_keys( $this->manifest['custom-post-type-title'] );
668
669 return array_diff( $manifest_post_types, Utils::get_builtin_wp_post_types() );
670 }
671
672 /**
673 * Get the default settings of elementor templates conditions to override.
674 *
675 * @return array
676 */
677 private function get_default_settings_conflicts() {
678 if ( empty( $this->manifest['templates'] ) ) {
679 return [];
680 }
681
682 return apply_filters( 'elementor/import/get_default_settings_conflicts', [], $this->manifest['templates'] );
683 }
684
685 /**
686 * Get the default settings of elementor templates conditions to override.
687 *
688 * @return array
689 */
690 private function get_default_settings_override_conditions() {
691 if ( empty( $this->settings_conflicts ) ) {
692 return [];
693 }
694
695 return array_keys( $this->settings_conflicts );
696 }
697
698 /**
699 * Get the default settings of the plugins that should be imported.
700 *
701 * @return array
702 */
703 private function get_default_settings_plugins() {
704 return ! empty( $this->manifest['plugins'] ) ? $this->manifest['plugins'] : [];
705 }
706
707 /**
708 * Get the default settings of which content types should be imported.
709 *
710 * @return array
711 */
712 private function get_default_settings_include() {
713 return [ 'templates', 'plugins', 'content', 'settings' ];
714 }
715
716 /**
717 * Get the data that requires updating/replacement when imported.
718 *
719 * @return array{post_ids: array, term_ids: array}
720 */
721 private function get_imported_data_replacements() : array {
722 return [
723 'post_ids' => Utils::map_old_new_post_ids( $this->imported_data ),
724 'term_ids' => Utils::map_old_new_term_ids( $this->imported_data ),
725 ];
726 }
727
728 /**
729 * Save the prevented elements on elementor post creation elements.
730 * Handle the replacement of all the dynamic content of the elements that probably have been changed during the import.
731 */
732 private function save_elements_of_imported_posts() {
733 $imported_data_replacements = $this->get_imported_data_replacements();
734
735 foreach ( $this->documents_data as $new_id => $data ) {
736 $document = Plugin::$instance->documents->get( $new_id );
737
738 if ( isset( $data['elements'] ) ) {
739 $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements );
740 }
741
742 if ( isset( $data['settings'] ) ) {
743
744 if ( $document instanceof Kit ) {
745 // Without post_status certain tabs in the Kit will not save properly.
746 $data['settings']['post_status'] = get_post_status( $new_id );
747 }
748
749 $data['settings'] = $document->on_import_update_settings( $data['settings'], $imported_data_replacements );
750 }
751
752 $document->save( $data );
753 }
754 }
755
756 private function update_instance_data_in_import_session_option() {
757 $import_sessions = get_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS );
758
759 $import_sessions[ $this->session_id ]['instance_data']['documents_data'] = $this->documents_data;
760 $import_sessions[ $this->session_id ]['instance_data']['imported_data'] = $this->imported_data;
761 $import_sessions[ $this->session_id ]['instance_data']['runners_import_metadata'] = $this->runners_import_metadata;
762
763 update_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS, $import_sessions, false );
764 }
765
766 private function finalize_import_session_option() {
767 $import_sessions = get_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS );
768
769 unset( $import_sessions[ $this->session_id ]['instance_data'] );
770
771 $import_sessions[ $this->session_id ]['end_timestamp'] = current_time( 'timestamp' );
772 $import_sessions[ $this->session_id ]['runners'] = $this->runners_import_metadata;
773
774 update_option( Module::OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS, $import_sessions, false );
775 }
776 }
777