PluginProbe
Elementor Website Builder – more than just a page builder / 3.31.2
Elementor Website Builder – more than just a page builder v3.31.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/module.php +46 -49 4.1.0-dev13.31.2 View file →
@@ -11,9 +11,8 @@
11 11 use Elementor\Plugin;
12 12 use Elementor\Tools;
13 13 use Elementor\Utils as ElementorUtils;
14 14 use Elementor\App\Modules\ImportExport\Utils as ImportExportUtils;
15 -use Elementor\Modules\CloudKitLibrary\Module as CloudKitLibrary;
16 15
17 16 if ( ! defined( 'ABSPATH' ) ) {
18 17 exit; // Exit if accessed directly.
19 18 }
@@ -134,10 +133,8 @@
134 133 /**
135 134 * Render the import/export tab content.
136 135 */
137 136 private function render_import_export_tab_content() {
138 - $is_cloud_kits_available = CloudKitLibrary::get_app()->check_eligibility()['is_eligible'];
139 -
140 137 $content_data = [
141 138 'export' => [
142 139 'title' => esc_html__( 'Export this website', 'elementor' ),
143 140 'button' => [
@@ -142,9 +139,8 @@
142 139 'title' => esc_html__( 'Export this website', 'elementor' ),
143 140 'button' => [
144 141 'url' => Plugin::$instance->app->get_base_url() . '#/export',
145 142 'text' => esc_html__( 'Export', 'elementor' ),
146 - 'id' => 'elementor-import-export__export',
147 143 ],
148 144 'description' => esc_html__( 'You can download this website as a .zip file, or upload it to the library.', 'elementor' ),
149 145 ],
150 146 'import' => [
@@ -151,19 +147,17 @@
151 147 'title' => esc_html__( 'Import website templates', 'elementor' ),
152 148 'button' => [
153 149 'url' => Plugin::$instance->app->get_base_url() . '#/import',
154 150 'text' => esc_html__( 'Import', 'elementor' ),
155 - 'id' => 'elementor-import-export__import',
156 151 ],
157 152 'description' => esc_html__( 'You can import design and settings from a .zip file or choose from the library.', 'elementor' ),
158 153 ],
159 154 ];
160 155
161 - if ( $is_cloud_kits_available ) {
156 + if ( Plugin::$instance->experiments->is_feature_active( 'cloud-library' ) ) {
162 157 $content_data['import']['button_secondary'] = [
163 158 'url' => Plugin::$instance->app->get_base_url() . '#/kit-library/cloud',
164 159 'text' => esc_html__( 'Import from library', 'elementor' ),
165 - 'id' => 'elementor-import-export__import_from_library',
166 160 ];
167 161 }
168 162
169 163 $last_imported_kit = $this->revert->get_last_import_session();
@@ -177,9 +171,8 @@
177 171
178 172 if ( $should_show_revert_section ) {
179 173 if ( ! empty( $penultimate_imported_kit ) ) {
180 174 $revert_text = sprintf(
181 - /* translators: 1: Last imported kit title, 2: Last imported kit date, 3: Line break <br>, 4: Penultimate imported kit title, 5: Penultimate imported kit date. */
182 175 esc_html__( 'Remove all the content and site settings that came with "%1$s" on %2$s %3$s and revert to the site setting that came with "%4$s" on %5$s.', 'elementor' ),
183 176 ! empty( $last_imported_kit['kit_title'] ) ? $last_imported_kit['kit_title'] : esc_html__( 'imported kit', 'elementor' ),
184 177 gmdate( $date_format, $last_imported_kit['start_timestamp'] ),
185 178 '<br>',
@@ -187,9 +180,8 @@
187 180 gmdate( $date_format, $penultimate_imported_kit['start_timestamp'] )
188 181 );
189 182 } else {
190 183 $revert_text = sprintf(
191 - /* translators: 1: Last imported kit title, 2: Last imported kit date, 3: Line break <br>. */
192 184 esc_html__( 'Remove all the content and site settings that came with "%1$s" on %2$s.%3$s Your original site settings will be restored.', 'elementor' ),
193 185 ! empty( $last_imported_kit['kit_title'] ) ? $last_imported_kit['kit_title'] : esc_html__( 'imported kit', 'elementor' ),
194 186 gmdate( $date_format, $last_imported_kit['start_timestamp'] ),
195 187 '<br>'
@@ -241,30 +233,43 @@
241 233 <?php
242 234 }
243 235
244 236 private function print_item_content( $data ) {
245 - ?>
246 - <div class="tab-import-export-kit__container">
247 - <div class="tab-import-export-kit__box">
248 - <h2><?php ElementorUtils::print_unescaped_internal_string( $data['title'] ); ?></h2>
237 + $is_cloud_kits_feature_active = Plugin::$instance->experiments->is_feature_active( 'cloud-library' );
238 +
239 + if ( $is_cloud_kits_feature_active ) { ?>
240 + <div class="tab-import-export-kit__container">
241 + <div class="tab-import-export-kit__box">
242 + <h2><?php ElementorUtils::print_unescaped_internal_string( $data['title'] ); ?></h2>
243 + </div>
244 + <p class="description"><?php ElementorUtils::print_unescaped_internal_string( $data['description'] ); ?></p>
245 +
246 + <?php if ( ! empty( $data['link'] ) ) : ?>
247 + <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['link']['url'] ); ?>" target="_blank"><?php ElementorUtils::print_unescaped_internal_string( $data['link']['text'] ); ?></a>
248 + <?php endif; ?>
249 + <div class="tab-import-export-kit__box action-buttons">
250 + <?php if ( ! empty( $data['button_secondary'] ) ) : ?>
251 + <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['url'] ); ?>" class="elementor-button e-btn-txt e-btn-txt-border">
252 + <?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['text'] ); ?>
253 + </a>
254 + <?php endif; ?>
255 + <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['button']['url'] ); ?>" class="elementor-button e-primary">
256 + <?php ElementorUtils::print_unescaped_internal_string( $data['button']['text'] ); ?>
257 + </a>
258 + </div>
249 259 </div>
250 - <p class="description"><?php ElementorUtils::print_unescaped_internal_string( $data['description'] ); ?></p>
251 -
252 - <?php if ( ! empty( $data['link'] ) ) : ?>
260 + <?php } else { ?>
261 + <div class="tab-import-export-kit__container">
262 + <div class="tab-import-export-kit__box">
263 + <h2><?php ElementorUtils::print_unescaped_internal_string( $data['title'] ); ?></h2>
264 + <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['button']['url'] ); ?>" class="elementor-button e-primary">
265 + <?php ElementorUtils::print_unescaped_internal_string( $data['button']['text'] ); ?>
266 + </a>
267 + </div>
268 + <p><?php ElementorUtils::print_unescaped_internal_string( $data['description'] ); ?></p>
253 269 <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['link']['url'] ); ?>" target="_blank"><?php ElementorUtils::print_unescaped_internal_string( $data['link']['text'] ); ?></a>
254 - <?php endif; ?>
255 - <div class="tab-import-export-kit__box action-buttons">
256 - <?php if ( ! empty( $data['button_secondary'] ) ) : ?>
257 - <a href="<?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['url'] ); ?>" class="elementor-button e-btn-txt e-btn-txt-border">
258 - <?php ElementorUtils::print_unescaped_internal_string( $data['button_secondary']['text'] ); ?>
259 - </a>
260 - <?php endif; ?>
261 - <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">
262 - <?php ElementorUtils::print_unescaped_internal_string( $data['button']['text'] ); ?>
263 - </a>
264 270 </div>
265 - </div>
266 - <?php
271 + <?php }
267 272 }
268 273
269 274 private function get_revert_href(): string {
270 275 $admin_post_url = admin_url( 'admin-post.php?action=elementor_revert_kit' );
@@ -328,9 +333,9 @@
328 333 * @param string $file Path to the file.
329 334 * @param string $referrer Referrer of the file 'local' or 'kit-library'.
330 335 * @param string $kit_id
331 336 * @return array
332 - * @throws \Exception If export validation fails or processing errors occur.
337 + * @throws \Exception
333 338 */
334 339 public function upload_kit( $file, $referrer, $kit_id = null ) {
335 340 $this->ensure_writing_permissions();
336 341
@@ -356,13 +361,13 @@
356 361 * Assigning the Import process to the 'import' property,
357 362 * so it will be available to use in different places such as: WP_Cli, Pro, etc.
358 363 *
359 364 * @param string $path Path to the file or session_id.
360 - * @param array $settings Settings the import use to determine which content to import.
361 - * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
362 - * @param bool $split_to_chunks Determine if the import process should be split into chunks.
365 + * @param array $settings Settings the import use to determine which content to import.
366 + * (e.g: include, selected_plugins, selected_cpt, selected_override_conditions, etc.)
367 + * @param bool $split_to_chunks Determine if the import process should be split into chunks.
363 368 * @return array
364 - * @throws \Exception If export configuration is invalid or processing fails.
369 + * @throws \Exception
365 370 */
366 371 public function import_kit( string $path, array $settings, bool $split_to_chunks = false ): array {
367 372 $this->ensure_writing_permissions();
368 373 $this->ensure_DOMDocument_exists();
@@ -393,9 +398,9 @@
393 398 *
394 399 * @return array Two types of response.
395 400 * 1. The status and the runner name.
396 401 * 2. The imported data. (Only if the runner is the last one in the import process)
397 - * @throws \Exception If import configuration is invalid or processing fails.
402 + * @throws \Exception
398 403 */
399 404 public function import_kit_by_runner( string $session_id, string $runner_name ): array {
400 405 // Check session_id
401 406 $this->import = Import::from_session( $session_id );
@@ -418,9 +423,9 @@
418 423 *
419 424 * @param array $settings Settings the export use to determine which content to export.
420 425 * (e.g: include, kit_info, selected_plugins, selected_cpt, etc.)
421 426 * @return array
422 - * @throws \Exception If import/export process fails or validation errors occur.
427 + * @throws \Exception
423 428 */
424 429 public function export_kit( array $settings ) {
425 430 $this->ensure_writing_permissions();
426 431
@@ -474,13 +479,11 @@
474 479 add_action( 'admin_post_elementor_revert_kit', [ $this, 'handle_revert_last_imported_kit' ] );
475 480
476 481 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
477 482
478 - if ( ! Plugin::$instance->experiments->is_feature_active( 'import-export-customization' ) ) {
479 - $page_id = Tools::PAGE_ID;
483 + $page_id = Tools::PAGE_ID;
480 484
481 - add_action( "elementor/admin/after_create_settings/{$page_id}", [ $this, 'register_settings_tab' ] );
482 - }
485 + add_action( "elementor/admin/after_create_settings/{$page_id}", [ $this, 'register_settings_tab' ] );
483 486
484 487 // TODO 18/04/2023 : This needs to be moved to the runner itself after https://elementor.atlassian.net/browse/HTS-434 is done.
485 488 if ( self::IMPORT_PLUGINS_ACTION === ElementorUtils::get_super_global_value( $_SERVER, 'HTTP_X_ELEMENTOR_ACTION' ) ) {
486 489 add_filter( 'woocommerce_create_pages', [ $this, 'empty_pages' ], 10, 0 );
@@ -616,10 +619,8 @@
616 619 }
617 620
618 621 /**
619 622 * Handle upload kit ajax request.
620 - *
621 - * @throws \Error If operation validation fails or processing errors occur.
622 623 */
623 624 private function handle_upload_kit() {
624 625 // PHPCS - A URL that should contain special chars (auth headers information).
625 626 $file_url = isset( $_POST['e_import_file'] )
@@ -644,9 +645,9 @@
644 645 throw new \Error( static::KIT_LIBRARY_ERROR_KEY ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
645 646 }
646 647
647 648 $import_result = apply_filters( 'elementor/import/kit/result', [ 'file_url' => $file_url ] );
648 - } elseif ( ! empty( $source ) ) {
649 + } else if ( ! empty( $source ) ) {
649 650 $import_result = apply_filters( 'elementor/import/kit/result/' . $source, [
650 651 'kit_id' => $kit_id,
651 652 'source' => $source,
652 653 ] );
@@ -770,10 +771,8 @@
770 771 }
771 772
772 773 /**
773 774 * Handle export kit ajax request.
774 - *
775 - * @throws \Error If cleanup process fails or file system errors occur.
776 775 */
777 776 private function handle_export_kit() {
778 777 // PHPCS - Already validated in caller function
779 778 $settings = json_decode( ElementorUtils::get_super_global_value( $_POST, 'data' ), true ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -781,9 +780,8 @@
781 780
782 781 $export = $this->export_kit( $settings );
783 782
784 783 $file_name = $export['file_name'];
785 - $file_size = filesize( $file_name );
786 784 $file = ElementorUtils::file_get_contents( $file_name );
787 785
788 786 if ( ! $file ) {
789 787 throw new \Error( 'Could not read the exported file.' );
@@ -800,9 +798,8 @@
800 798 $source,
801 799 $export,
802 800 $settings,
803 801 $file,
804 - $file_size,
805 802 );
806 803
807 804 if ( is_wp_error( $result ) ) {
808 805 wp_send_json_error( $result );
@@ -975,13 +972,13 @@
975 972 return $document ? $document->get_edit_url() : '';
976 973 }
977 974
978 975 /**
979 - * @param string $class_name
976 + * @param string $class
980 977 *
981 978 * @return bool
982 979 */
983 - public function is_third_party_class( $class_name ) {
980 + public function is_third_party_class( $class ) {
984 981 $allowed_classes = [
985 982 'Elementor\\',
986 983 'ElementorPro\\',
987 984 'WP_',
@@ -988,9 +985,9 @@
988 985 'wp_',
989 986 ];
990 987
991 988 foreach ( $allowed_classes as $allowed_class ) {
992 - if ( str_starts_with( $class_name, $allowed_class ) ) {
989 + if ( str_starts_with( $class, $allowed_class ) ) {
993 990 return false;
994 991 }
995 992 }
996 993