PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev3
Elementor Website Builder – more than just a page builder v3.32.0-dev3
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 | app/modules/import-export-customization/processes/import.php +33 -52 4.3.0-beta33.32.0-dev3 View file →
@@ -8,10 +8,8 @@
8 8 use Elementor\App\Modules\ImportExportCustomization\Compatibility\Customization;
9 9 use Elementor\App\Modules\ImportExportCustomization\Utils;
10 10 use Elementor\Core\Base\Document;
11 11 use Elementor\Core\Kits\Documents\Kit;
12 -use Elementor\Modules\AtomicWidgets\Utils\Atomic_Prop_Remap;
13 -use Elementor\Modules\Components\Module as Components_Module;
14 12 use Elementor\Plugin;
15 13
16 14 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Elementor_Content;
17 15 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Import_Runner_Base;
@@ -20,9 +18,8 @@
20 18 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Taxonomies;
21 19 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Templates;
22 20 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Wp_Content;
23 21 use Elementor\App\Modules\ImportExportCustomization\Module;
24 -use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Floating_Elements;
25 22
26 23 class Import {
27 24 const MANIFEST_ERROR_KEY = 'manifest-error';
28 25
@@ -149,11 +146,11 @@
149 146 */
150 147 private $runners_import_metadata = [];
151 148
152 149 /**
153 - * @param string $path session_id | zip_file_path
154 - * @param array $settings Use to determine which content to import.
155 - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
150 + * @param string $path session_id | zip_file_path
151 + * @param array $settings Use to determine which content to import.
152 + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
156 153 * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance.
157 154 * We are using it for quick creation of the instance when the import process is being split into chunks.
158 155 * @throws \Exception If the import session does not exist.
159 156 */
@@ -213,9 +210,8 @@
213 210
214 211 $this->manifest = $instance_data['manifest'];
215 212 $this->site_settings = $instance_data['site_settings'];
216 213
217 - $this->kit_id = $instance_data['kit_id'] ?? '';
218 214 $this->settings_include = $instance_data['settings_include'];
219 215 $this->settings_referrer = $instance_data['settings_referrer'];
220 216 $this->settings_conflicts = $instance_data['settings_conflicts'];
221 217 $this->settings_selected_override_conditions = $instance_data['settings_selected_override_conditions'];
@@ -264,9 +260,8 @@
264 260 $this->register( new Templates() );
265 261 $this->register( new Taxonomies() );
266 262 $this->register( new Elementor_Content() );
267 263 $this->register( new Wp_Content() );
268 - $this->register( new Floating_Elements() );
269 264 }
270 265
271 266 /**
272 267 * Set default settings for the import.
@@ -308,9 +303,18 @@
308 303 if ( empty( $this->runners ) ) {
309 304 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
310 305 }
311 306
312 - $data = $this->build_runner_data();
307 + $data = [
308 + 'session_id' => $this->session_id,
309 + 'include' => $this->settings_include,
310 + 'manifest' => $this->manifest,
311 + 'site_settings' => $this->site_settings,
312 + 'selected_plugins' => $this->settings_selected_plugins,
313 + 'customization' => $this->settings_customization,
314 + 'extracted_directory_path' => $this->extracted_directory_path,
315 + 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
316 + ];
313 317
314 318 $this->init_import_session();
315 319
316 320 remove_filter( 'elementor/document/save/data', [ Plugin::$instance->modules_manager->get_modules( 'content-sanitizer' ), 'sanitize_content' ] );
@@ -354,9 +358,18 @@
354 358 if ( empty( $this->runners ) ) {
355 359 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
356 360 }
357 361
358 - $data = $this->build_runner_data();
362 + $data = [
363 + 'session_id' => $this->session_id,
364 + 'include' => $this->settings_include,
365 + 'manifest' => $this->manifest,
366 + 'site_settings' => $this->site_settings,
367 + 'selected_plugins' => $this->settings_selected_plugins,
368 + 'customization' => $this->settings_customization,
369 + 'extracted_directory_path' => $this->extracted_directory_path,
370 + 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
371 + ];
359 372
360 373 add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 );
361 374
362 375 // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads.
@@ -401,18 +414,17 @@
401 414 * @return void
402 415 */
403 416 public function init_import_session( $save_instance_data = false ) {
404 417 $import_sessions = Utils::get_import_sessions( true );
405 - $existing_session = $import_sessions[ $this->session_id ] ?? [];
406 418
407 419 $import_sessions[ $this->session_id ] = [
408 420 'session_id' => $this->session_id,
409 421 'kit_title' => $this->manifest['title'] ?? '',
410 422 'kit_name' => $this->manifest['name'] ?? '',
411 - 'kit_thumbnail' => $existing_session['kit_thumbnail'] ?? $this->get_kit_thumbnail(),
412 - 'kit_source' => $existing_session['kit_source'] ?? $this->settings_referrer,
423 + 'kit_thumbnail' => $this->get_kit_thumbnail(),
424 + 'kit_source' => $this->settings_referrer,
413 425 'user_id' => get_current_user_id(),
414 - 'start_timestamp' => $existing_session['start_timestamp'] ?? current_time( 'timestamp' ),
426 + 'start_timestamp' => current_time( 'timestamp' ),
415 427 ];
416 428
417 429 if ( $save_instance_data ) {
418 430 $import_sessions[ $this->session_id ]['instance_data'] = [
@@ -422,9 +434,8 @@
422 434
423 435 'manifest' => $this->manifest,
424 436 'site_settings' => $this->site_settings,
425 437
426 - 'kit_id' => $this->kit_id,
427 438 'settings_include' => $this->settings_include,
428 439 'settings_referrer' => $this->settings_referrer,
429 440 'settings_conflicts' => $this->settings_conflicts,
430 441 'settings_selected_override_conditions' => $this->settings_selected_override_conditions,
@@ -454,29 +465,11 @@
454 465 return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer );
455 466 }
456 467
457 468 public function get_runners_name(): array {
458 - $data = $this->build_runner_data();
459 -
460 - return array_keys( array_filter(
461 - $this->runners,
462 - fn( $runner ) => $runner->should_import( $data )
463 - ) );
469 + return array_keys( $this->runners );
464 470 }
465 471
466 - private function build_runner_data(): array {
467 - return [
468 - 'session_id' => $this->session_id,
469 - 'include' => $this->settings_include,
470 - 'manifest' => $this->manifest,
471 - 'site_settings' => $this->site_settings,
472 - 'selected_plugins' => $this->settings_selected_plugins,
473 - 'customization' => $this->settings_customization,
474 - 'extracted_directory_path' => $this->extracted_directory_path,
475 - 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
476 - ];
477 - }
478 -
479 472 public function get_manifest() {
480 473 return $this->manifest;
481 474 }
482 475
@@ -586,9 +579,9 @@
586 579
587 580 /**
588 581 * Prevent saving elements on elementor post creation.
589 582 *
590 - * @param array $data
583 + * @param array $data
591 584 * @param Document $document
592 585 *
593 586 * @return array
594 587 */
@@ -611,9 +604,8 @@
611 604 * Extract the zip file.
612 605 *
613 606 * @param string $zip_path The path to the zip file.
614 607 * @return string The extracted directory path.
615 - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected.
616 608 */
617 609 private function extract_zip( $zip_path ) {
618 610 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
619 611
@@ -631,9 +623,8 @@
631 623 /**
632 624 * Get the manifest file from the extracted directory and adapt it if needed.
633 625 *
634 626 * @return string The manifest file content.
635 - * @throws \Error If import validation fails or processing errors occur.
636 627 */
637 628 private function read_manifest_json() {
638 629 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
639 630
@@ -689,8 +680,12 @@
689 680 *
690 681 * @return array Custom post types names.
691 682 */
692 683 private function get_default_settings_custom_post_types() {
684 + if ( empty( $this->manifest['custom-post-type-title'] ) ) {
685 + return [];
686 + }
687 +
693 688 $excluded = [ 'page', 'nav_menu_item' ];
694 689
695 690 if ( empty( $this->manifest['content']['post'] ?? [] ) && empty( $this->manifest['wp-content']['post'] ?? [] ) ) {
696 691 $excluded[] = 'post';
@@ -695,9 +690,9 @@
695 690 if ( empty( $this->manifest['content']['post'] ?? [] ) && empty( $this->manifest['wp-content']['post'] ?? [] ) ) {
696 691 $excluded[] = 'post';
697 692 }
698 693
699 - $manifest_post_types = array_keys( $this->manifest['custom-post-type-title'] ?? [] );
694 + $manifest_post_types = array_keys( $this->manifest['custom-post-type-title'] );
700 695
701 696 return array_merge( $manifest_post_types, Utils::get_builtin_wp_post_types( $excluded ) );
702 697 }
703 698
@@ -785,11 +780,8 @@
785 780 foreach ( $this->documents_data as $new_id => $data ) {
786 781 $document = Plugin::$instance->documents->get( $new_id );
787 782
788 783 if ( isset( $data['elements'] ) ) {
789 - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] );
790 - $data['elements'] = Atomic_Prop_Remap::apply( $data['elements'], $imported_data_replacements );
791 - $this->merge_atomic_prop_remap_warnings( Atomic_Prop_Remap::consume_warnings() );
792 784 $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements );
793 785 }
794 786
795 787 if ( isset( $data['settings'] ) ) {
@@ -803,19 +795,8 @@
803 795 }
804 796
805 797 $document->save( $data );
806 798 }
807 - }
808 -
809 - private function merge_atomic_prop_remap_warnings( array $warnings ): void {
810 - if ( empty( $warnings ) ) {
811 - return;
812 - }
813 -
814 - $existing = $this->runners_import_metadata['atomic_prop_remap']['warnings'] ?? [];
815 - $this->runners_import_metadata['atomic_prop_remap'] = [
816 - 'warnings' => array_merge( $existing, $warnings ),
817 - ];
818 799 }
819 800
820 801 private function update_instance_data_in_import_session_option() {
821 802 $import_sessions = Utils::get_import_sessions();