PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.2
Elementor Website Builder – more than just a page builder v3.20.2
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 -19 4.3.0-beta2 → 3.20.2 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
@@ -303,9 +302,8 @@
303 302 ];
304 303
305 304 $this->init_import_session();
306 305
307 - remove_filter( 'elementor/document/save/data', [ Plugin::$instance->modules_manager->get_modules( 'content-sanitizer' ), 'sanitize_content' ] );
308 306 add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 );
309 307
310 308 // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads.
311 309 Plugin::$instance->uploads_manager->set_elementor_upload_state( true );
@@ -445,9 +443,20 @@
445 443 if ( ! empty( $this->manifest['thumbnail'] ) ) {
446 444 return $this->manifest['thumbnail'];
447 445 }
448 446
449 - return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer );
447 + if ( empty( $this->kit_id ) ) {
448 + return '';
449 + }
450 +
451 + $api = new Kit_Library_Api();
452 + $kit = $api->get_by_id( $this->kit_id );
453 +
454 + if ( is_wp_error( $kit ) ) {
455 + return '';
456 + }
457 +
458 + return $kit->thumbnail;
450 459 }
451 460
452 461 public function get_runners_name(): array {
453 462 return array_keys( $this->runners );
@@ -560,9 +569,9 @@
560 569
561 570 /**
562 571 * Prevent saving elements on elementor post creation.
563 572 *
564 - * @param array $data
573 + * @param array $data
565 574 * @param Document $document
566 575 *
567 576 * @return array
568 577 */
@@ -585,9 +594,8 @@
585 594 * Extract the zip file.
586 595 *
587 596 * @param string $zip_path The path to the zip file.
588 597 * @return string The extracted directory path.
589 - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected.
590 598 */
591 599 private function extract_zip( $zip_path ) {
592 600 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
593 601
@@ -592,12 +600,12 @@
592 600 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
593 601
594 602 if ( is_wp_error( $extraction_result ) ) {
595 603 if ( isset( $extraction_result->errors['zip_error'] ) ) {
596 - throw new \Error( static::ZIP_ARCHIVE_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
604 + throw new \Error( static::ZIP_ARCHIVE_ERROR_KEY );
597 605 }
598 606
599 - throw new \Error( static::ZIP_FILE_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
607 + throw new \Error( static::ZIP_FILE_ERROR_KEY );
600 608 }
601 609
602 610 return $extraction_result['extraction_directory'];
603 611 }
@@ -605,10 +613,8 @@
605 613 /**
606 614 * Get the manifest file from the extracted directory and adapt it if needed.
607 615 *
608 616 * @return string The manifest file content.
609 - *
610 - * @throws \Error If import validation fails or processing errors occur.
611 617 */
612 618 private function read_manifest_json() {
613 619 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
614 620
@@ -613,9 +619,9 @@
613 619 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
614 620
615 621 if ( ! $manifest ) {
616 622 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
623 + throw new \Error( static::ZIP_FILE_ERROR_KEY );
618 624 }
619 625
620 626 $this->init_adapters( $manifest );
621 627
@@ -722,9 +728,9 @@
722 728 * Get the data that requires updating/replacement when imported.
723 729 *
724 730 * @return array{post_ids: array, term_ids: array}
725 731 */
726 - private function get_imported_data_replacements(): array {
732 + private function get_imported_data_replacements() : array {
727 733 return [
728 734 'post_ids' => Utils::map_old_new_post_ids( $this->imported_data ),
729 735 'term_ids' => Utils::map_old_new_term_ids( $this->imported_data ),
730 736 ];
@@ -740,9 +746,8 @@
740 746 foreach ( $this->documents_data as $new_id => $data ) {
741 747 $document = Plugin::$instance->documents->get( $new_id );
742 748
743 749 if ( isset( $data['elements'] ) ) {
744 - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] );
745 750 $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements );
746 751 }
747 752
748 753 if ( isset( $data['settings'] ) ) {