| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\App\Modules\Onboarding; |
| 4 | 4 | |
| 5 | 5 | use Elementor\App\Modules\Onboarding\Data\Controller; |
| 6 | +use Elementor\App\Modules\Onboarding\Data\Endpoints\Install_Theme; | |
| 6 | 7 | use Elementor\App\Modules\Onboarding\Storage\Entities\User_Choices; |
| 7 | 8 | use Elementor\App\Modules\Onboarding\Storage\Entities\User_Progress; |
| 8 | 9 | use Elementor\App\Modules\Onboarding\Storage\Onboarding_Progress_Manager; |
| 9 | 10 | use Elementor\Core\Base\Module as BaseModule; |
| @@ -120,9 +121,8 @@ | ||
| 120 | 121 | 'steps' => $steps, |
| 121 | 122 | 'uiTheme' => $this->get_ui_theme_preference(), |
| 122 | 123 | 'translations' => $this->get_translated_strings(), |
| 123 | 124 | 'shouldShowProInstallScreen' => $is_connected ? $this->should_show_pro_install_screen() : false, |
| 124 | - 'isHelloThemeActive' => $this->is_hello_theme_active(), | |
| 125 | 125 | 'urls' => [ |
| 126 | 126 | 'dashboard' => admin_url(), |
| 127 | 127 | 'editor' => admin_url( 'edit.php?post_type=elementor_library' ), |
| 128 | 128 | 'connect' => $this->get_connect_url(), |
| @@ -135,28 +135,21 @@ | ||
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | private function validate_progress_for_steps( User_Progress $progress, array $steps ): array { |
| 138 | 138 | $progress_data = $progress->to_array(); |
| 139 | - $step_ids = array_column( $steps, 'id' ); | |
| 140 | 139 | $step_count = count( $steps ); |
| 141 | - $fallback_step_id = $steps[0]['id'] ?? 'site_features'; | |
| 142 | 140 | $current_step_index = $progress->get_current_step_index() ?? 0; |
| 143 | - $current_step_id = $progress->get_current_step_id() ?? $fallback_step_id; | |
| 141 | + $current_step_id = $progress->get_current_step_id() ?? $steps[0]['id'] ?? 'building_for'; | |
| 144 | 142 | |
| 145 | 143 | $is_invalid_step_index = $current_step_index < 0 || $current_step_index >= $step_count; |
| 146 | - $is_invalid_step_id = ! in_array( $current_step_id, $step_ids, true ); | |
| 147 | 144 | |
| 148 | - if ( $is_invalid_step_index || $is_invalid_step_id ) { | |
| 149 | - $current_step_id = $fallback_step_id; | |
| 145 | + if ( $is_invalid_step_index ) { | |
| 146 | + $current_step_id = $steps[0]['id']; | |
| 150 | 147 | $current_step_index = 0; |
| 151 | 148 | } |
| 152 | 149 | |
| 153 | 150 | $progress_data['current_step_id'] = $current_step_id; |
| 154 | 151 | $progress_data['current_step_index'] = $current_step_index; |
| 155 | - $progress_data['completed_steps'] = array_values( array_filter( | |
| 156 | - $progress->get_completed_steps(), | |
| 157 | - static fn( $step_id ) => in_array( $step_id, $step_ids, true ) | |
| 158 | - ) ); | |
| 159 | 152 | |
| 160 | 153 | return $progress_data; |
| 161 | 154 | } |
| 162 | 155 | |
| @@ -193,9 +186,9 @@ | ||
| 193 | 186 | return $connect->get_app( 'library' ); |
| 194 | 187 | } |
| 195 | 188 | |
| 196 | 189 | public static function should_show_pro_install_screen(): bool { |
| 197 | - if ( Utils::has_pro() || Utils::is_pro_installed_and_not_active() ) { | |
| 190 | + if ( self::is_elementor_pro_installed() ) { | |
| 198 | 191 | return false; |
| 199 | 192 | } |
| 200 | 193 | |
| 201 | 194 | $connect = Plugin::$instance->common->get_component( 'connect' ); |
| @@ -318,13 +311,31 @@ | ||
| 318 | 311 | |
| 319 | 312 | private function get_steps_config(): array { |
| 320 | 313 | $steps = [ |
| 321 | 314 | [ |
| 315 | + 'id' => 'building_for', | |
| 316 | + 'label' => __( 'Who are you building for?', 'elementor' ), | |
| 317 | + 'type' => 'single', | |
| 318 | + ], | |
| 319 | + [ | |
| 320 | + 'id' => 'site_about', | |
| 321 | + 'label' => __( 'What is your site about?', 'elementor' ), | |
| 322 | + 'type' => 'multiple', | |
| 323 | + ], | |
| 324 | + [ | |
| 325 | + 'id' => 'experience_level', | |
| 326 | + 'label' => __( 'How much experience do you have with Elementor?', 'elementor' ), | |
| 327 | + 'type' => 'single', | |
| 328 | + ], | |
| 329 | + ]; | |
| 330 | + | |
| 331 | + if ( ! $this->is_elementor_theme_active() ) { | |
| 332 | + $steps[] = [ | |
| 322 | 333 | 'id' => 'theme_selection', |
| 323 | 334 | 'label' => __( 'Start with a theme that fits your needs', 'elementor' ), |
| 324 | 335 | 'type' => 'single', |
| 325 | - ], | |
| 326 | - ]; | |
| 336 | + ]; | |
| 337 | + } | |
| 327 | 338 | |
| 328 | 339 | if ( ! self::is_elementor_pro_installed() ) { |
| 329 | 340 | $steps[] = [ |
| 330 | 341 | 'id' => 'site_features', |
| @@ -336,17 +347,15 @@ | ||
| 336 | 347 | return apply_filters( 'elementor/onboarding/steps', $steps ); |
| 337 | 348 | } |
| 338 | 349 | |
| 339 | 350 | private static function is_elementor_pro_installed(): bool { |
| 340 | - $is_pro_installed = Utils::has_pro(); | |
| 351 | + $is_pro_installed = Utils::has_pro() || Utils::is_pro_installed_and_not_active(); | |
| 341 | 352 | return (bool) apply_filters( 'elementor/onboarding/is_elementor_pro_installed', $is_pro_installed ); |
| 342 | 353 | } |
| 343 | 354 | |
| 344 | - private function is_hello_theme_active(): bool { | |
| 355 | + private function is_elementor_theme_active(): bool { | |
| 345 | 356 | $active_theme = get_stylesheet(); |
| 346 | - $is_active = 0 === strpos( $active_theme, 'hello-' ); | |
| 347 | - | |
| 348 | - $is_active = (bool) apply_filters( 'elementor/onboarding/is_hello_theme_active', $is_active ); | |
| 357 | + $is_active = in_array( $active_theme, Install_Theme::ALLOWED_THEMES, true ); | |
| 349 | 358 | |
| 350 | 359 | return (bool) apply_filters( 'elementor/onboarding/is_elementor_theme_active', $is_active ); |
| 351 | 360 | } |
| 352 | 361 | } |