PluginProbe
Elementor Website Builder – more than just a page builder / 3.23.0-dev3
Elementor Website Builder – more than just a page builder v3.23.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/processes/import.php +24 -32 4.3.0-beta33.23.0-dev3 View file →
@@ -7,10 +7,8 @@
7 7 use Elementor\App\Modules\ImportExport\Compatibility\Kit_Library;
8 8 use Elementor\App\Modules\ImportExport\Utils;
9 9 use Elementor\Core\Base\Document;
10 10 use Elementor\Core\Kits\Documents\Kit;
11 -use Elementor\Modules\AtomicWidgets\Utils\Atomic_Prop_Remap;
12 -use Elementor\Modules\Components\Module as Components_Module;
13 11 use Elementor\Plugin;
14 12
15 13 use Elementor\App\Modules\ImportExport\Runners\Import\Elementor_Content;
16 14 use Elementor\App\Modules\ImportExport\Runners\Import\Import_Runner_Base;
@@ -19,8 +17,9 @@
19 17 use Elementor\App\Modules\ImportExport\Runners\Import\Taxonomies;
20 18 use Elementor\App\Modules\ImportExport\Runners\Import\Templates;
21 19 use Elementor\App\Modules\ImportExport\Runners\Import\Wp_Content;
22 20 use Elementor\App\Modules\ImportExport\Module;
21 +use Elementor\App\Modules\KitLibrary\Connect\Kit_Library as Kit_Library_Api;
23 22
24 23 class Import {
25 24 const MANIFEST_ERROR_KEY = 'manifest-error';
26 25
@@ -140,15 +139,14 @@
140 139 */
141 140 private $runners_import_metadata = [];
142 141
143 142 /**
144 - * @param string $path session_id | zip_file_path
145 - * @param array $settings Use to determine which content to import.
146 - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
143 + * @param string $path session_id | zip_file_path
144 + * @param array $settings Use to determine which content to import.
145 + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
147 146 * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance.
148 - * We are using it for quick creation of the instance when the import process is being split into chunks.
149 - *
150 - * @throws \Exception If the import session does not exist.
147 + * We are using it for quick creation of the instance when the import process is being split into chunks.
148 + * @throws \Exception
151 149 */
152 150 public function __construct( string $path, array $settings = [], array $old_instance = null ) {
153 151 if ( ! empty( $old_instance ) ) {
154 152 $this->set_import_object( $old_instance );
@@ -222,9 +220,9 @@
222 220 *
223 221 * @param string $session_id
224 222 *
225 223 * @return Import
226 - * @throws \Exception If the import session does not exist.
224 + * @throws \Exception
227 225 */
228 226 public static function from_session( string $session_id ): Import {
229 227 $import_sessions = Utils::get_import_sessions();
230 228
@@ -446,9 +444,20 @@
446 444 if ( ! empty( $this->manifest['thumbnail'] ) ) {
447 445 return $this->manifest['thumbnail'];
448 446 }
449 447
450 - return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer );
448 + if ( empty( $this->kit_id ) ) {
449 + return '';
450 + }
451 +
452 + $api = new Kit_Library_Api();
453 + $kit = $api->get_by_id( $this->kit_id );
454 +
455 + if ( is_wp_error( $kit ) ) {
456 + return '';
457 + }
458 +
459 + return $kit->thumbnail;
451 460 }
452 461
453 462 public function get_runners_name(): array {
454 463 return array_keys( $this->runners );
@@ -561,9 +570,9 @@
561 570
562 571 /**
563 572 * Prevent saving elements on elementor post creation.
564 573 *
565 - * @param array $data
574 + * @param array $data
566 575 * @param Document $document
567 576 *
568 577 * @return array
569 578 */
@@ -586,9 +595,8 @@
586 595 * Extract the zip file.
587 596 *
588 597 * @param string $zip_path The path to the zip file.
589 598 * @return string The extracted directory path.
590 - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected.
591 599 */
592 600 private function extract_zip( $zip_path ) {
593 601 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
594 602
@@ -593,12 +601,12 @@
593 601 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
594 602
595 603 if ( is_wp_error( $extraction_result ) ) {
596 604 if ( isset( $extraction_result->errors['zip_error'] ) ) {
597 - throw new \Error( static::ZIP_ARCHIVE_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
605 + throw new \Error( static::ZIP_ARCHIVE_ERROR_KEY );
598 606 }
599 607
600 - throw new \Error( static::ZIP_FILE_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
608 + throw new \Error( static::ZIP_FILE_ERROR_KEY );
601 609 }
602 610
603 611 return $extraction_result['extraction_directory'];
604 612 }
@@ -606,10 +614,8 @@
606 614 /**
607 615 * Get the manifest file from the extracted directory and adapt it if needed.
608 616 *
609 617 * @return string The manifest file content.
610 - *
611 - * @throws \Error If import validation fails or processing errors occur.
612 618 */
613 619 private function read_manifest_json() {
614 620 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
615 621
@@ -614,9 +620,9 @@
614 620 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
615 621
616 622 if ( ! $manifest ) {
617 623 Plugin::$instance->logger->get_logger()->error( static::MANIFEST_ERROR_KEY );
618 - throw new \Error( static::ZIP_FILE_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
624 + throw new \Error( static::ZIP_FILE_ERROR_KEY );
619 625 }
620 626
621 627 $this->init_adapters( $manifest );
622 628
@@ -723,9 +729,9 @@
723 729 * Get the data that requires updating/replacement when imported.
724 730 *
725 731 * @return array{post_ids: array, term_ids: array}
726 732 */
727 - private function get_imported_data_replacements(): array {
733 + private function get_imported_data_replacements() : array {
728 734 return [
729 735 'post_ids' => Utils::map_old_new_post_ids( $this->imported_data ),
730 736 'term_ids' => Utils::map_old_new_term_ids( $this->imported_data ),
731 737 ];
@@ -741,11 +747,8 @@
741 747 foreach ( $this->documents_data as $new_id => $data ) {
742 748 $document = Plugin::$instance->documents->get( $new_id );
743 749
744 750 if ( isset( $data['elements'] ) ) {
745 - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] );
746 - $data['elements'] = Atomic_Prop_Remap::apply( $data['elements'], $imported_data_replacements );
747 - $this->merge_atomic_prop_remap_warnings( Atomic_Prop_Remap::consume_warnings() );
748 751 $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements );
749 752 }
750 753
751 754 if ( isset( $data['settings'] ) ) {
@@ -759,19 +762,8 @@
759 762 }
760 763
761 764 $document->save( $data );
762 765 }
763 - }
764 -
765 - private function merge_atomic_prop_remap_warnings( array $warnings ): void {
766 - if ( empty( $warnings ) ) {
767 - return;
768 - }
769 -
770 - $existing = $this->runners_import_metadata['atomic_prop_remap']['warnings'] ?? [];
771 - $this->runners_import_metadata['atomic_prop_remap'] = [
772 - 'warnings' => array_merge( $existing, $warnings ),
773 - ];
774 766 }
775 767
776 768 private function update_instance_data_in_import_session_option() {
777 769 $import_sessions = Utils::get_import_sessions();