PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.2
Elementor Website Builder – more than just a page builder v3.22.2
4.3.2 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 All 455 releases
← All changes | app/modules/onboarding/module.php +11 -87 4.3.2 → 3.22.2 View file →
@@ -5,15 +5,15 @@
5 5 use Elementor\Core\Base\Module as BaseModule;
6 6 use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
7 7 use Elementor\Core\Common\Modules\Connect\Apps\Library;
8 8 use Elementor\Core\Files\Uploads_Manager;
9 -use Elementor\Includes\EditorAssetsAPI;
10 9 use Elementor\Plugin;
10 +use Elementor\Tracker;
11 11 use Elementor\Utils;
12 12 use Plugin_Upgrader;
13 13
14 14 if ( ! defined( 'ABSPATH' ) ) {
15 - exit; // Exit if accessed directly.
15 + exit; // Exit if accessed directly
16 16 }
17 17
18 18 /**
19 19 * Onboarding Module
@@ -26,16 +26,8 @@
26 26
27 27 const VERSION = '1.0.0';
28 28 const ONBOARDING_OPTION = 'elementor_onboarded';
29 29
30 - const EXPERIMENT_EMPHASIZE_CONNECT_BENEFITS = 'emphasizeConnectBenefits101';
31 - const EXPERIMENT_OFFER_THEME_CHOICES_HELLO_BIZ = 'offerThemeChoicesHelloBiz201';
32 - const EXPERIMENT_EMPHASIZE_THEME_VALUE_AUDIENCE_202 = 'emphasizeThemeValueAudience202';
33 - const EXPERIMENT_UPDATE_COPY_VISUALS = 'updateCopyVisuals401';
34 - const EXPERIMENT_REDUCE_HIERARCHY_BLANK_OPTION = 'reduceHierarchyBlankOption402';
35 -
36 - private ?API $editor_assets_api = null;
37 -
38 30 /**
39 31 * Get name.
40 32 *
41 33 * @since 3.6.0
@@ -46,44 +38,8 @@
46 38 public function get_name() {
47 39 return 'onboarding';
48 40 }
49 41
50 - private function is_experiment_enabled( string $experiment_key ) {
51 - $editor_assets_api = $this->get_editor_assets_api();
52 -
53 - if ( null === $editor_assets_api ) {
54 - return false;
55 - }
56 -
57 - return $editor_assets_api->is_experiment_enabled( $experiment_key );
58 - }
59 -
60 - private function is_hello_theme_activated(): bool {
61 - $current_theme = get_option( 'template' );
62 - $hello_theme_variants = [ 'hello-elementor', 'hello-biz', 'hello-commerce', 'hello-theme' ];
63 -
64 - return in_array( $current_theme, $hello_theme_variants, true );
65 - }
66 -
67 - private function get_editor_assets_api(): ?API {
68 - if ( null !== $this->editor_assets_api ) {
69 - return $this->editor_assets_api;
70 - }
71 -
72 - $editor_assets_api_instance = new EditorAssetsAPI( $this->get_editor_assets_api_config() );
73 - $this->editor_assets_api = new API( $editor_assets_api_instance );
74 -
75 - return $this->editor_assets_api;
76 - }
77 -
78 - private function get_editor_assets_api_config(): array {
79 - return [
80 - EditorAssetsAPI::ASSETS_DATA_URL => 'https://assets.elementor.com/ab-testing/v1/ab-testing.json',
81 - EditorAssetsAPI::ASSETS_DATA_TRANSIENT_KEY => '_elementor_ab_testing_data',
82 - EditorAssetsAPI::ASSETS_DATA_KEY => 'ab-testing',
83 - ];
84 - }
85 -
86 42 /**
87 43 * Set Onboarding Settings
88 44 *
89 45 * Creates an array of module settings that is localized into the JS App config.
@@ -112,9 +68,8 @@
112 68 $hello_theme_errors = is_object( $hello_theme->errors() ) ? $hello_theme->errors()->errors : [];
113 69
114 70 /** @var Library $library */
115 71 $library = Plugin::$instance->common->get_component( 'connect' )->get_app( 'library' );
116 - $is_editor_one_active = Plugin::$instance->experiments->is_feature_active( 'e_editor_one' );
117 72
118 73 Plugin::$instance->app->set_settings( 'onboarding', [
119 74 'eventPlacement' => 'Onboarding wizard',
120 75 'onboardingAlreadyRan' => get_option( self::ONBOARDING_OPTION ),
@@ -121,23 +76,15 @@
121 76 'onboardingVersion' => self::VERSION,
122 77 'isLibraryConnected' => $library->is_connected(),
123 78 // Used to check if the Hello Elementor theme is installed but not activated.
124 79 'helloInstalled' => empty( $hello_theme_errors['theme_not_found'] ),
125 - 'helloActivated' => $this->is_hello_theme_activated(),
80 + 'helloActivated' => 'hello-elementor' === get_option( 'template' ),
126 81 // The "Use Hello theme on my site" checkbox should be checked by default only if this condition is met.
127 82 'helloOptOut' => count( $pages_and_posts->posts ) < 5,
128 83 'siteName' => esc_html( $site_name ),
129 84 'isUnfilteredFilesEnabled' => Uploads_Manager::are_unfiltered_uploads_enabled(),
130 - 'isEditorOneActive' => $is_editor_one_active,
131 85 'urls' => [
132 - 'kitLibrary' => Plugin::$instance->app->get_base_url() . '&source=onboarding#/kit-library?order[direction]=desc&order[by]=featuredIndex',
133 - 'sitePlanner' => add_query_arg( [
134 - 'type' => 'editor',
135 - 'siteUrl' => esc_url( home_url() ),
136 - 'siteName' => esc_html( $site_name ),
137 - 'siteDescription' => esc_html( get_bloginfo( 'description' ) ),
138 - 'siteLanguage' => get_locale(),
139 - ], 'https://planner.elementor.com/onboarding.html' ),
86 + 'kitLibrary' => Plugin::$instance->app->get_base_url() . '#/kit-library?order[direction]=desc&order[by]=featuredIndex',
140 87 'createNewPage' => Plugin::$instance->documents->get_create_new_post_url(),
141 88 'connect' => $library->get_admin_url( 'authorize', [
142 89 'utm_source' => 'onboarding-wizard',
143 90 'utm_campaign' => 'connect-account',
@@ -166,23 +113,9 @@
166 113 'connectCtaLink' => '&utm_content=cta-link',
167 114 'downloadPro' => '?utm_source=onboarding-wizard&utm_campaign=my-account-subscriptions&utm_medium=wp-dash&utm_content=import-pro-plugin&utm_term=' . self::VERSION,
168 115 ],
169 116 'nonce' => wp_create_nonce( 'onboarding' ),
170 - 'experiment' => true,
171 - 'isExperiment101Enabled' => $this->is_experiment_enabled( self::EXPERIMENT_EMPHASIZE_CONNECT_BENEFITS ),
172 - 'isExperiment201Enabled' => $this->is_experiment_enabled( self::EXPERIMENT_OFFER_THEME_CHOICES_HELLO_BIZ ),
173 - 'isExperiment202Enabled' => $this->is_experiment_enabled( self::EXPERIMENT_EMPHASIZE_THEME_VALUE_AUDIENCE_202 ),
174 - 'isExperiment401Enabled' => $this->is_experiment_enabled( self::EXPERIMENT_UPDATE_COPY_VISUALS ),
175 - 'isExperiment402Enabled' => $this->is_experiment_enabled( self::EXPERIMENT_REDUCE_HIERARCHY_BLANK_OPTION ),
176 - 'experimentNames' => [
177 - '101' => self::EXPERIMENT_EMPHASIZE_CONNECT_BENEFITS,
178 - '201' => self::EXPERIMENT_OFFER_THEME_CHOICES_HELLO_BIZ,
179 - '202' => self::EXPERIMENT_EMPHASIZE_THEME_VALUE_AUDIENCE_202,
180 - '401' => self::EXPERIMENT_UPDATE_COPY_VISUALS,
181 - '402' => self::EXPERIMENT_REDUCE_HIERARCHY_BLANK_OPTION,
182 - ],
183 - 'pageSubheading' => $is_editor_one_active ? __( 'Choose the capabilities you need to bring your vision to life', 'elementor' ) : __( 'Which Elementor Pro features do you need to bring your creative vision to life?', 'elementor' ),
184 - 'pageHeading' => $is_editor_one_active ? __( ' Elevate your website with additional features.', 'elementor' ) : __( 'Elevate your website with additional Pro features.', 'elementor' ),
117 + 'experiment' => Plugin::$instance->experiments->is_feature_active( 'e_onboarding' ),
185 118 ] );
186 119 }
187 120
188 121 /**
@@ -324,9 +257,9 @@
324 257 */
325 258 private function maybe_upload_logo_image() {
326 259 $error_message = esc_html__( 'There was a problem uploading your file.', 'elementor' );
327 260
328 - $file = Utils::get_super_global_value( $_FILES, 'fileToUpload' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
261 + $file = Utils::get_super_global_value( $_FILES, 'fileToUpload' );
329 262
330 263 // phpcs:ignore WordPress.Security.NonceVerification.Missing
331 264 if ( ! is_array( $file ) || empty( $file['type'] ) ) {
332 265 return [
@@ -385,12 +318,10 @@
385 318 if ( ! current_user_can( 'switch_themes' ) ) {
386 319 return $this->get_permission_error_response();
387 320 }
388 321
389 - $theme_slug = 'hello-elementor';
322 + switch_theme( 'hello-elementor' );
390 323
391 - switch_theme( $theme_slug );
392 -
393 324 return [
394 325 'status' => 'success',
395 326 'payload' => [
396 327 'helloThemeActivated' => true,
@@ -411,9 +342,9 @@
411 342 }
412 343
413 344 $error_message = esc_html__( 'There was a problem uploading your file.', 'elementor' );
414 345
415 - $file = Utils::get_super_global_value( $_FILES, 'fileToUpload' ) ?? []; // phpcs:ignore WordPress.Security.NonceVerification.Missing
346 + $file = Utils::get_super_global_value( $_FILES, 'fileToUpload' ) ?? [];
416 347
417 348 // phpcs:ignore WordPress.Security.NonceVerification.Missing
418 349 if ( ! is_array( $file ) || empty( $file['type'] ) ) {
419 350 return [
@@ -481,10 +412,11 @@
481 412 /**
482 413 * Maybe Handle Ajax
483 414 *
484 415 * This method checks if there are any AJAX actions being
416 + * @since 3.6.0
485 417 *
486 - * @since 3.6.0
418 + * @return array|null
487 419 */
488 420 private function maybe_handle_ajax() {
489 421 $result = [];
490 422
@@ -490,9 +422,9 @@
490 422
491 423 // phpcs:ignore WordPress.Security.NonceVerification.Missing
492 424 switch ( Utils::get_super_global_value( $_POST, 'action' ) ) {
493 425 case 'elementor_update_site_name':
494 - // If no value is passed for any reason, no need to update the site name.
426 + // If no value is passed for any reason, no need ot update the site name.
495 427 $result = $this->maybe_update_site_name();
496 428 break;
497 429 case 'elementor_update_site_logo':
498 430 $result = $this->maybe_update_site_logo();
@@ -507,12 +439,8 @@
507 439 $result = $this->upload_and_install_pro();
508 440 break;
509 441 case 'elementor_update_onboarding_option':
510 442 $result = $this->maybe_update_onboarding_db_option();
511 - break;
512 - case 'elementor_save_onboarding_features':
513 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
514 - $result = $this->get_component( 'features_usage' )->save_onboarding_features( Utils::get_super_global_value( $_POST, 'data' ) ?? [] );
515 443 }
516 444
517 445 if ( ! empty( $result ) ) {
518 446 if ( 'success' === $result['status'] ) {
@@ -523,10 +451,8 @@
523 451 }
524 452 }
525 453
526 454 public function __construct() {
527 - $this->add_component( 'features_usage', new Features_Usage() );
528 -
529 455 add_action( 'elementor/init', function() {
530 456 // Only load when viewing the onboarding app.
531 457 if ( Plugin::$instance->app->is_current() ) {
532 458 $this->set_onboarding_settings();
@@ -556,8 +482,6 @@
556 482 ) {
557 483 $this->maybe_handle_ajax();
558 484 }
559 485 } );
560 -
561 - $this->get_component( 'features_usage' )->register();
562 486 }
563 487 }