PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.3
Elementor Website Builder – more than just a page builder v3.32.3
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 4.0.8 All 454 releases
← All changes | app/modules/import-export-customization/processes/import.php +28 -37 4.3.0-beta2 → 3.32.3 View file →
@@ -8,9 +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\Components\Module as Components_Module;
13 12 use Elementor\Plugin;
14 13
15 14 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Elementor_Content;
16 15 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Import_Runner_Base;
@@ -19,9 +18,8 @@
19 18 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Taxonomies;
20 19 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Templates;
21 20 use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Wp_Content;
22 21 use Elementor\App\Modules\ImportExportCustomization\Module;
23 -use Elementor\App\Modules\ImportExportCustomization\Runners\Import\Floating_Elements;
24 22
25 23 class Import {
26 24 const MANIFEST_ERROR_KEY = 'manifest-error';
27 25
@@ -148,11 +146,11 @@
148 146 */
149 147 private $runners_import_metadata = [];
150 148
151 149 /**
152 - * @param string $path session_id | zip_file_path
153 - * @param array $settings Use to determine which content to import.
154 - * (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.)
155 153 * @param array|null $old_instance An array of old instance parameters that will be used for creating new instance.
156 154 * We are using it for quick creation of the instance when the import process is being split into chunks.
157 155 * @throws \Exception If the import session does not exist.
158 156 */
@@ -212,9 +210,8 @@
212 210
213 211 $this->manifest = $instance_data['manifest'];
214 212 $this->site_settings = $instance_data['site_settings'];
215 213
216 - $this->kit_id = $instance_data['kit_id'] ?? '';
217 214 $this->settings_include = $instance_data['settings_include'];
218 215 $this->settings_referrer = $instance_data['settings_referrer'];
219 216 $this->settings_conflicts = $instance_data['settings_conflicts'];
220 217 $this->settings_selected_override_conditions = $instance_data['settings_selected_override_conditions'];
@@ -263,9 +260,8 @@
263 260 $this->register( new Templates() );
264 261 $this->register( new Taxonomies() );
265 262 $this->register( new Elementor_Content() );
266 263 $this->register( new Wp_Content() );
267 - $this->register( new Floating_Elements() );
268 264 }
269 265
270 266 /**
271 267 * Set default settings for the import.
@@ -307,9 +303,18 @@
307 303 if ( empty( $this->runners ) ) {
308 304 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
309 305 }
310 306
311 - $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 + ];
312 317
313 318 $this->init_import_session();
314 319
315 320 remove_filter( 'elementor/document/save/data', [ Plugin::$instance->modules_manager->get_modules( 'content-sanitizer' ), 'sanitize_content' ] );
@@ -353,9 +358,18 @@
353 358 if ( empty( $this->runners ) ) {
354 359 throw new \Exception( 'Couldn’t execute the import process because no import runners have been specified. Try again by specifying import runners.' );
355 360 }
356 361
357 - $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 + ];
358 372
359 373 add_filter( 'elementor/document/save/data', [ $this, 'prevent_saving_elements_on_post_creation' ], 10, 2 );
360 374
361 375 // Set the Request's state as an Elementor upload request, in order to support unfiltered file uploads.
@@ -400,18 +414,17 @@
400 414 * @return void
401 415 */
402 416 public function init_import_session( $save_instance_data = false ) {
403 417 $import_sessions = Utils::get_import_sessions( true );
404 - $existing_session = $import_sessions[ $this->session_id ] ?? [];
405 418
406 419 $import_sessions[ $this->session_id ] = [
407 420 'session_id' => $this->session_id,
408 421 'kit_title' => $this->manifest['title'] ?? '',
409 422 'kit_name' => $this->manifest['name'] ?? '',
410 - 'kit_thumbnail' => $existing_session['kit_thumbnail'] ?? $this->get_kit_thumbnail(),
411 - 'kit_source' => $existing_session['kit_source'] ?? $this->settings_referrer,
423 + 'kit_thumbnail' => $this->get_kit_thumbnail(),
424 + 'kit_source' => $this->settings_referrer,
412 425 'user_id' => get_current_user_id(),
413 - 'start_timestamp' => $existing_session['start_timestamp'] ?? current_time( 'timestamp' ),
426 + 'start_timestamp' => current_time( 'timestamp' ),
414 427 ];
415 428
416 429 if ( $save_instance_data ) {
417 430 $import_sessions[ $this->session_id ]['instance_data'] = [
@@ -421,9 +434,8 @@
421 434
422 435 'manifest' => $this->manifest,
423 436 'site_settings' => $this->site_settings,
424 437
425 - 'kit_id' => $this->kit_id,
426 438 'settings_include' => $this->settings_include,
427 439 'settings_referrer' => $this->settings_referrer,
428 440 'settings_conflicts' => $this->settings_conflicts,
429 441 'settings_selected_override_conditions' => $this->settings_selected_override_conditions,
@@ -453,29 +465,11 @@
453 465 return apply_filters( 'elementor/import/kit_thumbnail', '', $this->kit_id, $this->settings_referrer );
454 466 }
455 467
456 468 public function get_runners_name(): array {
457 - $data = $this->build_runner_data();
458 -
459 - return array_keys( array_filter(
460 - $this->runners,
461 - fn( $runner ) => $runner->should_import( $data )
462 - ) );
469 + return array_keys( $this->runners );
463 470 }
464 471
465 - private function build_runner_data(): array {
466 - return [
467 - 'session_id' => $this->session_id,
468 - 'include' => $this->settings_include,
469 - 'manifest' => $this->manifest,
470 - 'site_settings' => $this->site_settings,
471 - 'selected_plugins' => $this->settings_selected_plugins,
472 - 'customization' => $this->settings_customization,
473 - 'extracted_directory_path' => $this->extracted_directory_path,
474 - 'selected_custom_post_types' => $this->settings_selected_custom_post_types,
475 - ];
476 - }
477 -
478 472 public function get_manifest() {
479 473 return $this->manifest;
480 474 }
481 475
@@ -585,9 +579,9 @@
585 579
586 580 /**
587 581 * Prevent saving elements on elementor post creation.
588 582 *
589 - * @param array $data
583 + * @param array $data
590 584 * @param Document $document
591 585 *
592 586 * @return array
593 587 */
@@ -610,9 +604,8 @@
610 604 * Extract the zip file.
611 605 *
612 606 * @param string $zip_path The path to the zip file.
613 607 * @return string The extracted directory path.
614 - * @throws \Error If import process fails, file validation errors occur, or data corruption is detected.
615 608 */
616 609 private function extract_zip( $zip_path ) {
617 610 $extraction_result = Plugin::$instance->uploads_manager->extract_and_validate_zip( $zip_path, [ 'json', 'xml' ] );
618 611
@@ -630,9 +623,8 @@
630 623 /**
631 624 * Get the manifest file from the extracted directory and adapt it if needed.
632 625 *
633 626 * @return string The manifest file content.
634 - * @throws \Error If import validation fails or processing errors occur.
635 627 */
636 628 private function read_manifest_json() {
637 629 $manifest = Utils::read_json_file( $this->extracted_directory_path . 'manifest' );
638 630
@@ -784,9 +776,8 @@
784 776 foreach ( $this->documents_data as $new_id => $data ) {
785 777 $document = Plugin::$instance->documents->get( $new_id );
786 778
787 779 if ( isset( $data['elements'] ) ) {
788 - $data['elements'] = Components_Module::prepare_imported_elements( $data['elements'], $imported_data_replacements['post_ids'] ?? [] );
789 780 $data['elements'] = $document->on_import_update_dynamic_content( $data['elements'], $imported_data_replacements );
790 781 }
791 782
792 783 if ( isset( $data['settings'] ) ) {