← All changes
|
app/modules/import-export-customization/processes/import.php
+12
-15
4.0.8
→
3.32.0-dev3
View file →
| @@ -18,9 +18,8 @@ | ||
| 18 | 18 | use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Taxonomies; |
| 19 | 19 | use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Templates; |
| 20 | 20 | use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Wp_Content; |
| 21 | 21 | use Elementor\App\Modules\ImportExportCustomization\Module; |
| 22 | -use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Floating_Elements; | |
| 23 | 22 | |
| 24 | 23 | class Import { |
| 25 | 24 | const MANIFEST_ERROR_KEY = 'manifest-error'; |
| 26 | 25 | |
| @@ -147,11 +146,11 @@ | ||
| 147 | 146 | */ |
| 148 | 147 | private $runners_import_metadata = []; |
| 149 | 148 | |
| 150 | 149 | /** |
| 151 | - * @param string $path session_id | zip_file_path | |
| 152 | - * @param array $settings Use to determine which content to import. | |
| 153 | - * (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.) | |
| 154 | 153 | * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance. |
| 155 | 154 | * We are using it for quick creation of the instance when the import process is being split into chunks. |
| 156 | 155 | * @throws \Exception If the import session does not exist. |
| 157 | 156 | */ |
| @@ -211,9 +210,8 @@ | ||
| 211 | 210 | |
| 212 | 211 | $this->manifest = $instance_data['manifest']; |
| 213 | 212 | $this->site_settings = $instance_data['site_settings']; |
| 214 | 213 | |
| 215 | - $this->kit_id = $instance_data['kit_id'] ?? ''; | |
| 216 | 214 | $this->settings_include = $instance_data['settings_include']; |
| 217 | 215 | $this->settings_referrer = $instance_data['settings_referrer']; |
| 218 | 216 | $this->settings_conflicts = $instance_data['settings_conflicts']; |
| 219 | 217 | $this->settings_selected_override_conditions = $instance_data['settings_selected_override_conditions']; |
| @@ -262,9 +260,8 @@ | ||
| 262 | 260 | $this->register( new Templates() ); |
| 263 | 261 | $this->register( new Taxonomies() ); |
| 264 | 262 | $this->register( new Elementor_Content() ); |
| 265 | 263 | $this->register( new Wp_Content() ); |
| 266 | - $this->register( new Floating_Elements() ); | |
| 267 | 264 | } |
| 268 | 265 | |
| 269 | 266 | /** |
| 270 | 267 | * Set default settings for the import. |
| @@ -417,18 +414,17 @@ | ||
| 417 | 414 | * @return void |
| 418 | 415 | */ |
| 419 | 416 | public function init_import_session( $save_instance_data = false ) { |
| 420 | 417 | $import_sessions = Utils::get_import_sessions( true ); |
| 421 | - $existing_session = $import_sessions[ $this->session_id ] ?? []; | |
| 422 | 418 | |
| 423 | 419 | $import_sessions[ $this->session_id ] = [ |
| 424 | 420 | 'session_id' => $this->session_id, |
| 425 | 421 | 'kit_title' => $this->manifest['title'] ?? '', |
| 426 | 422 | 'kit_name' => $this->manifest['name'] ?? '', |
| 427 | - 'kit_thumbnail' => $existing_session['kit_thumbnail'] ?? $this->get_kit_thumbnail(), | |
| 428 | - 'kit_source' => $existing_session['kit_source'] ?? $this->settings_referrer, | |
| 423 | + 'kit_thumbnail' => $this->get_kit_thumbnail(), | |
| 424 | + 'kit_source' => $this->settings_referrer, | |
| 429 | 425 | 'user_id' => get_current_user_id(), |
| 430 | - 'start_timestamp' => $existing_session['start_timestamp'] ?? current_time( 'timestamp' ), | |
| 426 | + 'start_timestamp' => current_time( 'timestamp' ), | |
| 431 | 427 | ]; |
| 432 | 428 | |
| 433 | 429 | if ( $save_instance_data ) { |
| 434 | 430 | $import_sessions[ $this->session_id ]['instance_data'] = [ |
| @@ -438,9 +434,8 @@ | ||
| 438 | 434 | |
| 439 | 435 | 'manifest' => $this->manifest, |
| 440 | 436 | 'site_settings' => $this->site_settings, |
| 441 | 437 | |
| 442 | - 'kit_id' => $this->kit_id, | |
| 443 | 438 | 'settings_include' => $this->settings_include, |
| 444 | 439 | 'settings_referrer' => $this->settings_referrer, |
| 445 | 440 | 'settings_conflicts' => $this->settings_conflicts, |
| 446 | 441 | 'settings_selected_override_conditions' => $this->settings_selected_override_conditions, |
| @@ -584,9 +579,9 @@ | ||
| 584 | 579 | |
| 585 | 580 | /** |
| 586 | 581 | * Prevent saving elements on elementor post creation. |
| 587 | 582 | * |
| 588 | - * @param array $data | |
| 583 | + * @param array $data | |
| 589 | 584 | * @param Document $document |
| 590 | 585 | * |
| 591 | 586 | * @return array |
| 592 | 587 | */ |
| @@ -609,9 +604,8 @@ | ||
| 609 | 604 | * Extract the zip file. |
| 610 | 605 | * |
| 611 | 606 | * @param string $zip_path The path to the zip file. |
| 612 | 607 | * @return string The extracted directory path. |
| 613 | - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected. | |
| 614 | 608 | */ |
| 615 | 609 | private function extract_zip( $zip_path ) { |
| 616 | 610 | $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] ); |
| 617 | 611 | |
| @@ -629,9 +623,8 @@ | ||
| 629 | 623 | /** |
| 630 | 624 | * Get the manifest file from the extracted directory and adapt it if needed. |
| 631 | 625 | * |
| 632 | 626 | * @return string The manifest file content. |
| 633 | - * @throws \Error If import validation fails or processing errors occur. | |
| 634 | 627 | */ |
| 635 | 628 | private function read_manifest_json() { |
| 636 | 629 | $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' ); |
| 637 | 630 | |
| @@ -687,8 +680,12 @@ | ||
| 687 | 680 | * |
| 688 | 681 | * @return array Custom post types names. |
| 689 | 682 | */ |
| 690 | 683 | private function get_default_settings_custom_post_types() { |
| 684 | + if ( empty( $this->manifest['custom-post-type-title'] ) ) { | |
| 685 | + return []; | |
| 686 | + } | |
| 687 | + | |
| 691 | 688 | $excluded = [ 'page', 'nav_menu_item' ]; |
| 692 | 689 | |
| 693 | 690 | if ( empty( $this->manifest['content']['post'] ?? [] ) && empty( $this->manifest['wp-content']['post'] ?? [] ) ) { |
| 694 | 691 | $excluded[] = 'post'; |
| @@ -693,9 +690,9 @@ | ||
| 693 | 690 | if ( empty( $this->manifest['content']['post'] ?? [] ) && empty( $this->manifest['wp-content']['post'] ?? [] ) ) { |
| 694 | 691 | $excluded[] = 'post'; |
| 695 | 692 | } |
| 696 | 693 | |
| 697 | - $manifest_post_types = array_keys( $this->manifest['custom-post-type-title'] ?? [] ); | |
| 694 | + $manifest_post_types = array_keys( $this->manifest['custom-post-type-title'] ); | |
| 698 | 695 | |
| 699 | 696 | return array_merge( $manifest_post_types, Utils::get_builtin_wp_post_types( $excluded ) ); |
| 700 | 697 | } |
| 701 | 698 | |