← All changes
|
app/modules/import-export/processes/import.php
+18
-10
4.2.0-dev2
→
3.28.0-dev2
View file →
| @@ -17,8 +17,9 @@ | ||
| 17 | 17 | use Elementor\App\Modules\ImportExport\Runners\Import\Taxonomies; |
| 18 | 18 | use Elementor\App\Modules\ImportExport\Runners\Import\Templates; |
| 19 | 19 | use Elementor\App\Modules\ImportExport\Runners\Import\Wp_Content; |
| 20 | 20 | use Elementor\App\Modules\ImportExport\Module; |
| 21 | +use Elementor\App\Modules\KitLibrary\Connect\Kit_Library as Kit_Library_Api; | |
| 21 | 22 | |
| 22 | 23 | class Import { |
| 23 | 24 | const MANIFEST_ERROR_KEY = 'manifest-error'; |
| 24 | 25 | |
| @@ -138,14 +139,13 @@ | ||
| 138 | 139 | */ |
| 139 | 140 | private $runners_import_metadata = []; |
| 140 | 141 | |
| 141 | 142 | /** |
| 142 | - * @param string $path session_id | zip_file_path | |
| 143 | - * @param array $settings Use to determine which content to import. | |
| 144 | - * (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.) | |
| 145 | 146 | * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance. |
| 146 | - * We are using it for quick creation of the instance when the import process is being split into chunks. | |
| 147 | - * | |
| 147 | + * We are using it for quick creation of the instance when the import process is being split into chunks. | |
| 148 | 148 | * @throws \Exception If the import session does not exist. |
| 149 | 149 | */ |
| 150 | 150 | public function __construct( string $path, array $settings = [], array $old_instance = null ) { |
| 151 | 151 | if ( ! empty( $old_instance ) ) { |
| @@ -444,9 +444,20 @@ | ||
| 444 | 444 | if ( ! empty( $this->manifest['thumbnail'] ) ) { |
| 445 | 445 | return $this->manifest['thumbnail']; |
| 446 | 446 | } |
| 447 | 447 | |
| 448 | - 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; | |
| 449 | 460 | } |
| 450 | 461 | |
| 451 | 462 | public function get_runners_name(): array { |
| 452 | 463 | return array_keys( $this->runners ); |
| @@ -559,9 +570,9 @@ | ||
| 559 | 570 | |
| 560 | 571 | /** |
| 561 | 572 | * Prevent saving elements on elementor post creation. |
| 562 | 573 | * |
| 563 | - * @param array $data | |
| 574 | + * @param array $data | |
| 564 | 575 | * @param Document $document |
| 565 | 576 | * |
| 566 | 577 | * @return array |
| 567 | 578 | */ |
| @@ -584,9 +595,8 @@ | ||
| 584 | 595 | * Extract the zip file. |
| 585 | 596 | * |
| 586 | 597 | * @param string $zip_path The path to the zip file. |
| 587 | 598 | * @return string The extracted directory path. |
| 588 | - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected. | |
| 589 | 599 | */ |
| 590 | 600 | private function extract_zip( $zip_path ) { |
| 591 | 601 | $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] ); |
| 592 | 602 | |
| @@ -604,10 +614,8 @@ | ||
| 604 | 614 | /** |
| 605 | 615 | * Get the manifest file from the extracted directory and adapt it if needed. |
| 606 | 616 | * |
| 607 | 617 | * @return string The manifest file content. |
| 608 | - * | |
| 609 | - * @throws \Error If import validation fails or processing errors occur. | |
| 610 | 618 | */ |
| 611 | 619 | private function read_manifest_json() { |
| 612 | 620 | $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' ); |
| 613 | 621 | |