← All changes
|
app/modules/import-export-customization/processes/import.php
+24
-29
4.1.0
→
3.33.0-beta1
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 | |
| @@ -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. |
| @@ -306,9 +303,18 @@ | ||
| 306 | 303 | if ( empty( $this->runners ) ) { |
| 307 | 304 | throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' ); |
| 308 | 305 | } |
| 309 | 306 | |
| 310 | - $data = $this->build_runner_data(); | |
| 307 | + $data = [ | |
| 308 | + 'session_id' => $this->session_id, | |
| 309 | + 'include' => $this->settings_include, | |
| 310 | + 'manifest' => $this->manifest, | |
| 311 | + 'site_settings' => $this->site_settings, | |
| 312 | + 'selected_plugins' => $this->settings_selected_plugins, | |
| 313 | + 'customization' => $this->settings_customization, | |
| 314 | + 'extracted_directory_path' => $this->extracted_directory_path, | |
| 315 | + 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 316 | + ]; | |
| 311 | 317 | |
| 312 | 318 | $this->init_import_session(); |
| 313 | 319 | |
| 314 | 320 | remove_filter( 'elementor/document/save/data', [ Plugin::$instance->modules_manager->get_modules( 'content-sanitizer' ), 'sanitize_content' ] ); |
| @@ -352,9 +358,18 @@ | ||
| 352 | 358 | if ( empty( $this->runners ) ) { |
| 353 | 359 | throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' ); |
| 354 | 360 | } |
| 355 | 361 | |
| 356 | - $data = $this->build_runner_data(); | |
| 362 | + $data = [ | |
| 363 | + 'session_id' => $this->session_id, | |
| 364 | + 'include' => $this->settings_include, | |
| 365 | + 'manifest' => $this->manifest, | |
| 366 | + 'site_settings' => $this->site_settings, | |
| 367 | + 'selected_plugins' => $this->settings_selected_plugins, | |
| 368 | + 'customization' => $this->settings_customization, | |
| 369 | + 'extracted_directory_path' => $this->extracted_directory_path, | |
| 370 | + 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 371 | + ]; | |
| 357 | 372 | |
| 358 | 373 | add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 ); |
| 359 | 374 | |
| 360 | 375 | // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads. |
| @@ -399,18 +414,17 @@ | ||
| 399 | 414 | * @return void |
| 400 | 415 | */ |
| 401 | 416 | public function init_import_session( $save_instance_data = false ) { |
| 402 | 417 | $import_sessions = Utils::get_import_sessions( true ); |
| 403 | - $existing_session = $import_sessions[ $this->session_id ] ?? []; | |
| 404 | 418 | |
| 405 | 419 | $import_sessions[ $this->session_id ] = [ |
| 406 | 420 | 'session_id' => $this->session_id, |
| 407 | 421 | 'kit_title' => $this->manifest['title'] ?? '', |
| 408 | 422 | 'kit_name' => $this->manifest['name'] ?? '', |
| 409 | - 'kit_thumbnail' => $existing_session['kit_thumbnail'] ?? $this->get_kit_thumbnail(), | |
| 410 | - 'kit_source' => $existing_session['kit_source'] ?? $this->settings_referrer, | |
| 423 | + 'kit_thumbnail' => $this->get_kit_thumbnail(), | |
| 424 | + 'kit_source' => $this->settings_referrer, | |
| 411 | 425 | 'user_id' => get_current_user_id(), |
| 412 | - 'start_timestamp' => $existing_session['start_timestamp'] ?? current_time( 'timestamp' ), | |
| 426 | + 'start_timestamp' => current_time( 'timestamp' ), | |
| 413 | 427 | ]; |
| 414 | 428 | |
| 415 | 429 | if ( $save_instance_data ) { |
| 416 | 430 | $import_sessions[ $this->session_id ]['instance_data'] = [ |
| @@ -420,9 +434,8 @@ | ||
| 420 | 434 | |
| 421 | 435 | 'manifest' => $this->manifest, |
| 422 | 436 | 'site_settings' => $this->site_settings, |
| 423 | 437 | |
| 424 | - 'kit_id' => $this->kit_id, | |
| 425 | 438 | 'settings_include' => $this->settings_include, |
| 426 | 439 | 'settings_referrer' => $this->settings_referrer, |
| 427 | 440 | 'settings_conflicts' => $this->settings_conflicts, |
| 428 | 441 | 'settings_selected_override_conditions' => $this->settings_selected_override_conditions, |
| @@ -452,27 +465,9 @@ | ||
| 452 | 465 | return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer ); |
| 453 | 466 | } |
| 454 | 467 | |
| 455 | 468 | public function get_runners_name(): array { |
| 456 | - $data = $this->build_runner_data(); | |
| 457 | - | |
| 458 | - return array_keys( array_filter( | |
| 459 | - $this->runners, | |
| 460 | - fn( $runner ) => $runner->should_import( $data ) | |
| 461 | - ) ); | |
| 462 | - } | |
| 463 | - | |
| 464 | - private function build_runner_data(): array { | |
| 465 | - return [ | |
| 466 | - 'session_id' => $this->session_id, | |
| 467 | - 'include' => $this->settings_include, | |
| 468 | - 'manifest' => $this->manifest, | |
| 469 | - 'site_settings' => $this->site_settings, | |
| 470 | - 'selected_plugins' => $this->settings_selected_plugins, | |
| 471 | - 'customization' => $this->settings_customization, | |
| 472 | - 'extracted_directory_path' => $this->extracted_directory_path, | |
| 473 | - 'selected_custom_post_types' => $this->settings_selected_custom_post_types, | |
| 474 | - ]; | |
| 469 | + return array_keys( $this->runners ); | |
| 475 | 470 | } |
| 476 | 471 | |
| 477 | 472 | public function get_manifest() { |
| 478 | 473 | return $this->manifest; |