PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.2
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 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | app/modules/import-export-customization/module.php +32 -82 4.1.13.32.2 View file →
@@ -6,12 +6,9 @@
6 6 use Elementor\App\Modules\ImportExportCustomization\Processes\Revert;
7 7 use Elementor\Core\Base\Module as BaseModule;
8 8 use Elementor\Core\Files\Uploads_Manager;
9 9 use Elementor\Modules\CloudKitLibrary\Module as CloudKitLibrary;
10 -use Elementor\Modules\GlobalClasses\Global_Classes_REST_API;
11 10 use Elementor\Modules\System_Info\Reporters\Server;
12 -use Elementor\Modules\Variables\Storage\Constants;
13 -use Elementor\Modules\Variables\Storage\Variables_Collection;
14 11 use Elementor\Plugin;
15 12 use Elementor\Tools;
16 13 use Elementor\Utils as ElementorUtils;
17 14 use Elementor\App\Modules\ImportExportCustomization\Utils as ImportExportUtils;
@@ -39,10 +36,8 @@
39 36 const PLUGIN_PERMISSIONS_ERROR_KEY = 'plugin-installation-permissions-error';
40 37
41 38 const KIT_LIBRARY_ERROR_KEY = 'invalid-kit-library-zip-error';
42 39
43 - const CLOUD_KIT_LIBRARY_ERROR_LOADING_RESOURCE = 'error-loading-resource';
44 -
45 40 const NO_WRITE_PERMISSIONS_KEY = 'no-write-permissions';
46 41
47 42 const THIRD_PARTY_ERROR = 'third-party-error';
48 43
@@ -47,10 +42,8 @@
47 42 const THIRD_PARTY_ERROR = 'third-party-error';
48 43
49 44 const DOMDOCUMENT_MISSING = 'domdocument-missing';
50 45
51 - const MEDIA_PROCESSING_ERROR = 'media-processing-error';
52 -
53 46 const OPTION_KEY_ELEMENTOR_IMPORT_SESSIONS = 'elementor_import_sessions';
54 47
55 48 const OPTION_KEY_ELEMENTOR_REVERT_SESSIONS = 'elementor_revert_sessions';
56 49
@@ -160,15 +153,10 @@
160 153 ],
161 154 ];
162 155
163 156 if ( $is_cloud_kits_available ) {
164 - $return_to_url = Tools::get_url() . '#tab-import-export-kit';
165 - $kit_library_url = add_query_arg(
166 - [ 'return_to' => rawurlencode( $return_to_url ) ],
167 - Plugin::$instance->app->get_base_url() . '#/kit-library/cloud'
168 - );
169 157 $content_data['import']['button_secondary'] = [
170 - 'url' => $kit_library_url,
158 + 'url' => Plugin::$instance->app->get_base_url() . '#/kit-library/cloud',
171 159 'text' => esc_html__( 'Import from library', 'elementor' ),
172 160 'id' => 'elementor-import-export__import_from_library',
173 161 ];
174 162 }
@@ -248,11 +236,10 @@
248 236 <?php
249 237 }
250 238
251 239 private function print_item_content( $data ) {
252 - $container_classes = 'tab-import-export-kit__container e-editor-one';
253 240 ?>
254 - <div class="<?php echo esc_attr( $container_classes ); ?>">
241 + <div class="tab-import-export-kit__container">
255 242 <div class="tab-import-export-kit__box">
256 243 <h2><?php ElementorUtils::print_unescaped_internal_string( $data['title'] ); ?></h2>
257 244 </div>
258 245 <p class="description"><?php ElementorUtils::print_unescaped_internal_string( $data['description'] ); ?></p>
@@ -261,9 +248,9 @@
261 248 <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['link']['url'] ); ?>" target="_blank"><?php ElementorUtils::print_unescaped_internal_string( $data['link']['text'] ); ?></a>
262 249 <?php endif; ?>
263 250 <div class="tab-import-export-kit__box action-buttons">
264 251 <?php if ( ! empty( $data['button_secondary'] ) ) : ?>
265 - <a id="<?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['id'] ); ?>" href="<?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['url'] ); ?>" class="elementor-button e-btn-txt e-btn-txt-border">
252 + <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['url'] ); ?>" class="elementor-button e-btn-txt e-btn-txt-border">
266 253 <?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['text'] ); ?>
267 254 </a>
268 255 <?php endif; ?>
269 256 <a <?php ElementorUtils::print_html_attributes( [ 'id' => $data['button']['id'] ] ); ?> href="<?php ElementorUtils::print_unescaped_internal_string( $data['button']['url'] ); ?>" class="elementor-button e-primary">
@@ -274,10 +261,11 @@
274 261 <?php
275 262 }
276 263
277 264 private function get_revert_href(): string {
278 - $current_url = add_query_arg( null, null );
279 - return $this->maybe_add_referrer_param( $current_url );
265 + $admin_post_url = admin_url( 'admin-post.php?action=elementor_revert_kit' );
266 + $nonced_admin_post_url = wp_nonce_url( $admin_post_url, 'elementor_revert_kit' );
267 + return $this->maybe_add_referrer_param( $nonced_admin_post_url );
280 268 }
281 269
282 270 /**
283 271 * Checks if referred by a kit and adds the referrer ID to the href
@@ -296,18 +284,8 @@
296 284 return add_query_arg( $param_name, sanitize_key( $_GET[ $param_name ] ), $href );
297 285 }
298 286
299 287 /**
300 - * Get referrer kit ID from current request
301 - *
302 - * @return string
303 - */
304 - private function get_referrer_kit_id_from_request(): string {
305 - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Called via REST API with its own authentication
306 - return sanitize_key( $_GET['referrer_kit'] ?? '' );
307 - }
308 -
309 - /**
310 288 * Render the last kit thumbnail if exists
311 289 *
312 290 * @param $last_imported_kit
313 291 *
@@ -345,9 +323,9 @@
345 323 * @param string $file Path to the file.
346 324 * @param string $referrer Referrer of the file 'local' or 'kit-library'.
347 325 * @param string $kit_id
348 326 * @return array
349 - * @throws \Exception If customization validation fails or processing errors occur.
327 + * @throws \Exception
350 328 */
351 329 public function upload_kit( $file, $referrer, $kit_id = null ) {
352 330 $this->ensure_writing_permissions();
353 331
@@ -355,10 +333,8 @@
355 333 'referrer' => $referrer,
356 334 'id' => $kit_id,
357 335 ] );
358 336
359 - $this->save_upload_session_data();
360 -
361 337 return [
362 338 'session' => $this->import->get_session_id(),
363 339 'manifest' => $this->import->get_manifest(),
364 340 'conflicts' => $this->import->get_settings_conflicts(),
@@ -375,13 +351,13 @@
375 351 * Assigning the Import process to the 'import' property,
376 352 * so it will be available to use in different places such as: WP_Cli, Pro, etc.
377 353 *
378 354 * @param string $path Path to the file or session_id.
379 - * @param array $settings Settings the import use to determine which content to import.
380 - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
381 - * @param bool $split_to_chunks Determine if the import process should be split into chunks.
355 + * @param array $settings Settings the import use to determine which content to import.
356 + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
357 + * @param bool $split_to_chunks Determine if the import process should be split into chunks.
382 358 * @return array
383 - * @throws \Exception If export configuration is invalid or processing fails.
359 + * @throws \Exception
384 360 */
385 361 public function import_kit( string $path, array $settings, bool $split_to_chunks = false ): array {
386 362 $this->ensure_writing_permissions();
387 363 $this->ensure_DOMDocument_exists();
@@ -403,12 +379,8 @@
403 379
404 380 return $this->import->run();
405 381 }
406 382
407 - private function save_upload_session_data(): void {
408 - $this->import->init_import_session();
409 - }
410 -
411 383 /**
412 384 * Resuming import process by re-creating the import instance and running the specific runner.
413 385 *
414 386 * @param string $session_id The id off the import session.
@@ -416,9 +388,9 @@
416 388 *
417 389 * @return array Two types of response.
418 390 * 1. The status and the runner name.
419 391 * 2. The imported data. (Only if the runner is the last one in the import process)
420 - * @throws \Exception If export configuration is invalid or processing fails.
392 + * @throws \Exception
421 393 */
422 394 public function import_kit_by_runner( string $session_id, string $runner_name ): array {
423 395 // Check session_id
424 396 $this->import = Import::from_session( $session_id );
@@ -441,9 +413,9 @@
441 413 *
442 414 * @param array $settings Settings the export use to determine which content to export.
443 415 * (e.g: include, kit_info, selected_plugins, selected_cpt, etc.)
444 416 * @return array
445 - * @throws \Exception If export configuration is invalid or processing fails.
417 + * @throws \Exception
446 418 */
447 419 public function export_kit( array $settings ) {
448 420 $this->ensure_writing_permissions();
449 421
@@ -455,36 +427,30 @@
455 427 return $this->export->run();
456 428 }
457 429
458 430 /**
459 - * Handle revert kit request.
431 + * Handle revert kit ajax request.
460 432 */
461 - public function revert_last_imported_kit(): array {
433 + public function revert_last_imported_kit() {
462 434 $this->revert = new Revert();
463 435 $this->revert->register_default_runners();
464 436
465 - $import_sessions = Revert::get_import_sessions();
437 + do_action( 'elementor/import-export-customization/revert-kit', $this->revert );
466 438
467 - if ( empty( $import_sessions ) ) {
468 - return [
469 - 'revert_completed' => false,
470 - 'message' => __( 'No import sessions available to revert.', 'elementor' ),
471 - 'referrer_kit_id' => $this->get_referrer_kit_id_from_request(),
472 - 'show_referrer_dialog' => false,
473 - ];
474 - }
439 + $this->revert->run();
440 + }
475 441
476 - do_action( 'elementor/import-export-customization/revert-kit', $this->revert );
477 442
478 - $this->revert->run();
443 + /**
444 + * Handle revert last imported kit ajax request.
445 + */
446 + public function handle_revert_last_imported_kit() {
447 + check_admin_referer( 'elementor_revert_kit' );
479 448
480 - $referrer_kit_id = $this->get_referrer_kit_id_from_request();
449 + $this->revert_last_imported_kit();
481 450
482 - return [
483 - 'revert_completed' => true,
484 - 'referrer_kit_id' => $referrer_kit_id,
485 - 'show_referrer_dialog' => ! empty( $referrer_kit_id ),
486 - ];
451 + wp_safe_redirect( admin_url( 'admin.php?page=' . Tools::PAGE_ID . '#tab-import-export-kit' ) );
452 + die;
487 453 }
488 454
489 455 /**
490 456 * Register appropriate actions.
@@ -489,8 +455,10 @@
489 455 /**
490 456 * Register appropriate actions.
491 457 */
492 458 private function register_actions() {
459 + add_action( 'admin_post_elementor_revert_kit', [ $this, 'handle_revert_last_imported_kit' ] );
460 +
493 461 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
494 462
495 463 $page_id = Tools::PAGE_ID;
496 464
@@ -584,9 +552,9 @@
584 552
585 553 wp_enqueue_script(
586 554 'import-export-customization-admin',
587 555 $this->get_js_assets_url( 'import-export-customization-admin' ),
588 - [ 'elementor-common', 'wp-api-fetch' ],
556 + [ 'elementor-common' ],
589 557 ELEMENTOR_VERSION,
590 558 true
591 559 );
592 560 }
@@ -626,16 +594,13 @@
626 594 'importSessions' => Revert::get_import_sessions(),
627 595 'lastImportedSession' => $this->revert->get_last_import_session(),
628 596 'kitPreviewNonce' => wp_create_nonce( 'kit_thumbnail' ),
629 597 'restApiBaseUrl' => Controller::get_base_url(),
630 - 'restNonce' => wp_create_nonce( 'wp_rest' ),
631 - 'restUrl' => rest_url(),
632 598 'uiTheme' => $this->get_elementor_ui_theme_preference(),
633 599 'exportGroups' => $this->get_export_groups(),
634 600 'manifestVersion' => self::FORMAT_VERSION,
635 601 'elementorVersion' => ELEMENTOR_VERSION,
636 602 'upgradeVersionUrl' => admin_url( 'plugins.php' ),
637 - 'limits' => $this->get_limits(),
638 603 ];
639 604 }
640 605
641 606 private function get_elementor_ui_theme_preference() {
@@ -654,23 +619,8 @@
654 619
655 620 return $export_groups;
656 621 }
657 622
658 - private function get_limits() {
659 - $classes_limit = class_exists( Global_Classes_REST_API::class )
660 - ? Global_Classes_REST_API::MAX_ITEMS
661 - : 100;
662 -
663 - $variables_limit = class_exists( Constants::class )
664 - ? Constants::TOTAL_VARIABLES_COUNT
665 - : 100;
666 -
667 - return [
668 - 'classes' => $classes_limit,
669 - 'variables' => $variables_limit,
670 - ];
671 - }
672 -
673 623 /**
674 624 * Get labels of Elementor document types, Elementor Post types, WordPress Post types and Custom Post types.
675 625 */
676 626 private function get_summary_titles() {
@@ -783,13 +733,13 @@
783 733 return $document ? $document->get_edit_url() : '';
784 734 }
785 735
786 736 /**
787 - * @param string $class_name
737 + * @param string $class
788 738 *
789 739 * @return bool
790 740 */
791 - public function is_third_party_class( $class_name ) {
741 + public function is_third_party_class( $class ) {
792 742 $allowed_classes = [
793 743 'Elementor\\',
794 744 'ElementorPro\\',
795 745 'WP_',
@@ -796,9 +746,9 @@
796 746 'wp_',
797 747 ];
798 748
799 749 foreach ( $allowed_classes as $allowed_class ) {
800 - if ( str_starts_with( $class_name, $allowed_class ) ) {
750 + if ( str_starts_with( $class, $allowed_class ) ) {
801 751 return false;
802 752 }
803 753 }
804 754