| @@ -26,14 +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 | 30 | private ?API $editor_assets_api = null; |
| 37 | 31 | |
| 38 | 32 | /** |
| 39 | 33 | * Get name. |
| @@ -46,9 +40,9 @@ | ||
| 46 | 40 | public function get_name() { |
| 47 | 41 | return 'onboarding'; |
| 48 | 42 | } |
| 49 | 43 | |
| 50 | - private function is_experiment_enabled( string $experiment_key ) { | |
| 44 | + private function is_theme_selection_experiment_enabled() { | |
| 51 | 45 | $editor_assets_api = $this->get_editor_assets_api(); |
| 52 | 46 | |
| 53 | 47 | if ( null === $editor_assets_api ) { |
| 54 | 48 | return false; |
| @@ -53,16 +47,19 @@ | ||
| 53 | 47 | if ( null === $editor_assets_api ) { |
| 54 | 48 | return false; |
| 55 | 49 | } |
| 56 | 50 | |
| 57 | - return $editor_assets_api->is_experiment_enabled( $experiment_key ); | |
| 51 | + return $editor_assets_api->is_theme_selection_experiment_enabled(); | |
| 58 | 52 | } |
| 59 | 53 | |
| 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' ]; | |
| 54 | + private function is_good_to_go_experiment_enabled() { | |
| 55 | + $editor_assets_api = $this->get_editor_assets_api(); | |
| 63 | 56 | |
| 64 | - return in_array( $current_theme, $hello_theme_variants, true ); | |
| 57 | + if ( null === $editor_assets_api ) { | |
| 58 | + return false; | |
| 59 | + } | |
| 60 | + | |
| 61 | + return $editor_assets_api->is_good_to_go_experiment_enabled(); | |
| 65 | 62 | } |
| 66 | 63 | |
| 67 | 64 | private function get_editor_assets_api(): ?API { |
| 68 | 65 | if ( null !== $this->editor_assets_api ) { |
| @@ -112,9 +109,8 @@ | ||
| 112 | 109 | $hello_theme_errors = is_object( $hello_theme->errors() ) ? $hello_theme->errors()->errors : []; |
| 113 | 110 | |
| 114 | 111 | /** @var Library $library */ |
| 115 | 112 | $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 | 113 | |
| 118 | 114 | Plugin::$instance->app->set_settings( 'onboarding', [ |
| 119 | 115 | 'eventPlacement' => 'Onboarding wizard', |
| 120 | 116 | 'onboardingAlreadyRan' => get_option( self::ONBOARDING_OPTION ), |
| @@ -121,14 +117,13 @@ | ||
| 121 | 117 | 'onboardingVersion' => self::VERSION, |
| 122 | 118 | 'isLibraryConnected' => $library->is_connected(), |
| 123 | 119 | // Used to check if the Hello Elementor theme is installed but not activated. |
| 124 | 120 | 'helloInstalled' => empty( $hello_theme_errors['theme_not_found'] ), |
| 125 | - 'helloActivated' => $this->is_hello_theme_activated(), | |
| 121 | + 'helloActivated' => 'hello-elementor' === get_option( 'template' ), | |
| 126 | 122 | // The "Use Hello theme on my site" checkbox should be checked by default only if this condition is met. |
| 127 | 123 | 'helloOptOut' => count( $pages_and_posts->posts ) < 5, |
| 128 | 124 | 'siteName' => esc_html( $site_name ), |
| 129 | 125 | 'isUnfilteredFilesEnabled' => Uploads_Manager::are_unfiltered_uploads_enabled(), |
| 130 | - 'isEditorOneActive' => $is_editor_one_active, | |
| 131 | 126 | 'urls' => [ |
| 132 | 127 | 'kitLibrary' => Plugin::$instance->app->get_base_url() . '&source=onboarding#/kit-library?order[direction]=desc&order[by]=featuredIndex', |
| 133 | 128 | 'sitePlanner' => add_query_arg( [ |
| 134 | 129 | 'type' => 'editor', |
| @@ -167,22 +162,10 @@ | ||
| 167 | 162 | 'downloadPro' => '?utm_source=onboarding-wizard&utm_campaign=my-account-subscriptions&utm_medium=wp-dash&utm_content=import-pro-plugin&utm_term=' . self::VERSION, |
| 168 | 163 | ], |
| 169 | 164 | 'nonce' => wp_create_nonce( 'onboarding' ), |
| 170 | 165 | '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' ), | |
| 166 | + 'themeSelectionExperimentEnabled' => $this->is_theme_selection_experiment_enabled(), | |
| 167 | + 'goodToGoExperimentEnabled' => $this->is_good_to_go_experiment_enabled(), | |
| 185 | 168 | ] ); |
| 186 | 169 | } |
| 187 | 170 | |
| 188 | 171 | /** |
| @@ -385,9 +368,13 @@ | ||
| 385 | 368 | if ( ! current_user_can( 'switch_themes' ) ) { |
| 386 | 369 | return $this->get_permission_error_response(); |
| 387 | 370 | } |
| 388 | 371 | |
| 389 | - $theme_slug = 'hello-elementor'; | |
| 372 | + $theme_slug = Utils::get_super_global_value( $_POST, 'theme_slug' ) ?? 'hello-biz'; // phpcs:ignore WordPress.Security.NonceVerification.Missing | |
| 373 | + $allowed_themes = [ 'hello-elementor', 'hello-biz' ]; | |
| 374 | + if ( ! in_array( $theme_slug, $allowed_themes, true ) ) { | |
| 375 | + $theme_slug = 'hello-biz'; | |
| 376 | + } | |
| 390 | 377 | |
| 391 | 378 | switch_theme( $theme_slug ); |
| 392 | 379 | |
| 393 | 380 | return [ |