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