← All changes
|
app/modules/import-export-customization/processes/import.php
+21
-37
4.3.0-beta3
→
3.35.0-dev4
View file →
| @@ -8,10 +8,8 @@ | ||
| 8 | 8 | use Elementor\App\Modules\ImportExportCustomization\Compatibility\Customization; |
| 9 | 9 | use Elementor\App\Modules\ImportExportCustomization\Utils; |
| 10 | 10 | use Elementor\Core\Base\Document; |
| 11 | 11 | use Elementor\Core\Kits\Documents\Kit; |
| 12 | -use Elementor\Modules\AtomicWidgets\Utils\Atomic_Prop_Remap; | |
| 13 | -use Elementor\Modules\Components\Module as Components_Module; | |
| 14 | 12 | use Elementor\Plugin; |
| 15 | 13 | |
| 16 | 14 | use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Elementor_Content; |
| 17 | 15 | use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Import_Runner_Base; |
| @@ -308,9 +306,18 @@ | ||
| 308 | 306 | if ( empty( $this->runners ) ) { |
| 309 | 307 | throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' ); |
| 310 | 308 | } |
| 311 | 309 | |
| 312 | - $data = $this->build_runner_data(); | |
| 310 | + $data = [ | |
| 311 | + 'session_id' => $this->session_id, | |
| 312 | + 'include' => $this->settings_include, | |
| 313 | + 'manifest' => $this->manifest, | |
| 314 | + 'site_settings' => $this->site_settings, | |
| 315 | + 'selected_plugins' => $this->settings_selected_plugins, | |
| 316 | + 'customization' => $this->settings_customization, | |
| 317 | + 'extracted_directory_path' => $this->extracted_directory_path, | |
| 318 | + 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 319 | + ]; | |
| 313 | 320 | |
| 314 | 321 | $this->init_import_session(); |
| 315 | 322 | |
| 316 | 323 | remove_filter( 'elementor/document/save/data', [ Plugin::$instance->modules_manager->get_modules( 'content-sanitizer' ), 'sanitize_content' ] ); |
| @@ -354,9 +361,18 @@ | ||
| 354 | 361 | if ( empty( $this->runners ) ) { |
| 355 | 362 | throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' ); |
| 356 | 363 | } |
| 357 | 364 | |
| 358 | - $data = $this->build_runner_data(); | |
| 365 | + $data = [ | |
| 366 | + 'session_id' => $this->session_id, | |
| 367 | + 'include' => $this->settings_include, | |
| 368 | + 'manifest' => $this->manifest, | |
| 369 | + 'site_settings' => $this->site_settings, | |
| 370 | + 'selected_plugins' => $this->settings_selected_plugins, | |
| 371 | + 'customization' => $this->settings_customization, | |
| 372 | + 'extracted_directory_path' => $this->extracted_directory_path, | |
| 373 | + 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 374 | + ]; | |
| 359 | 375 | |
| 360 | 376 | add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 ); |
| 361 | 377 | |
| 362 | 378 | // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads. |
| @@ -454,29 +470,11 @@ | ||
| 454 | 470 | return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer ); |
| 455 | 471 | } |
| 456 | 472 | |
| 457 | 473 | public function get_runners_name(): array { |
| 458 | - $data = $this->build_runner_data(); | |
| 459 | - | |
| 460 | - return array_keys( array_filter( | |
| 461 | - $this->runners, | |
| 462 | - fn( $runner ) => $runner->should_import( $data ) | |
| 463 | - ) ); | |
| 474 | + return array_keys( $this->runners ); | |
| 464 | 475 | } |
| 465 | 476 | |
| 466 | - private function build_runner_data(): array { | |
| 467 | - return [ | |
| 468 | - 'session_id' => $this->session_id, | |
| 469 | - 'include' => $this->settings_include, | |
| 470 | - 'manifest' => $this->manifest, | |
| 471 | - 'site_settings' => $this->site_settings, | |
| 472 | - 'selected_plugins' => $this->settings_selected_plugins, | |
| 473 | - 'customization' => $this->settings_customization, | |
| 474 | - 'extracted_directory_path' => $this->extracted_directory_path, | |
| 475 | - 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 476 | - ]; | |
| 477 | - } | |
| 478 | - | |
| 479 | 477 | public function get_manifest() { |
| 480 | 478 | return $this->manifest; |
| 481 | 479 | } |
| 482 | 480 | |
| @@ -785,11 +783,8 @@ | ||
| 785 | 783 | foreach ( $this->documents_data as $new_id => $data ) { |
| 786 | 784 | $document = Plugin::$instance->documents->get( $new_id ); |
| 787 | 785 | |
| 788 | 786 | if ( isset( $data['elements'] ) ) { |
| 789 | - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] ); | |
| 790 | - $data['elements'] = Atomic_Prop_Remap::apply( $data['elements'], $imported_data_replacements ); | |
| 791 | - $this->merge_atomic_prop_remap_warnings( Atomic_Prop_Remap::consume_warnings() ); | |
| 792 | 787 | $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements ); |
| 793 | 788 | } |
| 794 | 789 | |
| 795 | 790 | if ( isset( $data['settings'] ) ) { |
| @@ -803,19 +798,8 @@ | ||
| 803 | 798 | } |
| 804 | 799 | |
| 805 | 800 | $document->save( $data ); |
| 806 | 801 | } |
| 807 | - } | |
| 808 | - | |
| 809 | - private function merge_atomic_prop_remap_warnings( array $warnings ): void { | |
| 810 | - if ( empty( $warnings ) ) { | |
| 811 | - return; | |
| 812 | - } | |
| 813 | - | |
| 814 | - $existing = $this->runners_import_metadata['atomic_prop_remap']['warnings'] ?? []; | |
| 815 | - $this->runners_import_metadata['atomic_prop_remap'] = [ | |
| 816 | - 'warnings' => array_merge( $existing, $warnings ), | |
| 817 | - ]; | |
| 818 | 802 | } |
| 819 | 803 | |
| 820 | 804 | private function update_instance_data_in_import_session_option() { |
| 821 | 805 | $import_sessions = Utils::get_import_sessions(); |