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