PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | app/modules/onboarding/module.php +19 -68 4.1.24.3.0-beta3 View file →
@@ -2,9 +2,8 @@
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;
7 6 use Elementor\App\Modules\Onboarding\Storage\Entities\User_Choices;
8 7 use Elementor\App\Modules\Onboarding\Storage\Entities\User_Progress;
9 8 use Elementor\App\Modules\Onboarding\Storage\Onboarding_Progress_Manager;
10 9 use Elementor\Core\Base\Module as BaseModule;
@@ -51,15 +50,8 @@
51 50
52 51 Plugin::instance()->data_manager_v2->register_controller( new Controller() );
53 52
54 53 add_action( 'elementor/init', [ $this, 'on_elementor_init' ], 12 );
55 -
56 - if ( $this->should_show_starter() ) {
57 - add_filter( 'elementor/editor/localize_settings', [ $this, 'add_starter_settings' ] );
58 - add_filter( 'elementor/editor/v2/packages', [ $this, 'add_starter_packages' ] );
59 - add_action( 'elementor/editor/v2/styles/enqueue', [ $this, 'enqueue_fonts' ] );
60 - add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_starter_preview_css' ] );
61 - }
62 54 }
63 55
64 56 public function on_elementor_init(): void {
65 57 if ( ! Plugin::instance()->app->is_current() ) {
@@ -78,19 +70,8 @@
78 70 ELEMENTOR_VERSION
79 71 );
80 72 }
81 73
82 - public function enqueue_starter_preview_css(): void {
83 - $css = '
84 - #site-header,
85 - .page-header { display: var(--e-starter-header-display, none); }
86 - ';
87 -
88 - wp_register_style( 'elementor-starter-preview', false );
89 - wp_enqueue_style( 'elementor-starter-preview' );
90 - wp_add_inline_style( 'elementor-starter-preview', $css );
91 - }
92 -
93 74 public function progress_manager(): Onboarding_Progress_Manager {
94 75 return $this->progress_manager;
95 76 }
96 77
@@ -121,8 +102,9 @@
121 102 'steps' => $steps,
122 103 'uiTheme' => $this->get_ui_theme_preference(),
123 104 'translations' => $this->get_translated_strings(),
124 105 'shouldShowProInstallScreen' => $is_connected ? $this->should_show_pro_install_screen() : false,
106 + 'isHelloThemeActive' => $this->is_hello_theme_active(),
125 107 'urls' => [
126 108 'dashboard' => admin_url(),
127 109 'editor' => admin_url( 'edit.php?post_type=elementor_library' ),
128 110 'connect' => $this->get_connect_url(),
@@ -135,21 +117,28 @@
135 117 }
136 118
137 119 private function validate_progress_for_steps( User_Progress $progress, array $steps ): array {
138 120 $progress_data = $progress->to_array();
121 + $step_ids = array_column( $steps, 'id' );
139 122 $step_count = count( $steps );
123 + $fallback_step_id = $steps[0]['id'] ?? 'site_features';
140 124 $current_step_index = $progress->get_current_step_index() ?? 0;
141 - $current_step_id = $progress->get_current_step_id() ?? $steps[0]['id'] ?? 'building_for';
125 + $current_step_id = $progress->get_current_step_id() ?? $fallback_step_id;
142 126
143 127 $is_invalid_step_index = $current_step_index < 0 || $current_step_index >= $step_count;
128 + $is_invalid_step_id = ! in_array( $current_step_id, $step_ids, true );
144 129
145 - if ( $is_invalid_step_index ) {
146 - $current_step_id = $steps[0]['id'];
130 + if ( $is_invalid_step_index || $is_invalid_step_id ) {
131 + $current_step_id = $fallback_step_id;
147 132 $current_step_index = 0;
148 133 }
149 134
150 135 $progress_data['current_step_id'] = $current_step_id;
151 136 $progress_data['current_step_index'] = $current_step_index;
137 + $progress_data['completed_steps'] = array_values( array_filter(
138 + $progress->get_completed_steps(),
139 + static fn( $step_id ) => in_array( $step_id, $step_ids, true )
140 + ) );
152 141
153 142 return $progress_data;
154 143 }
155 144
@@ -186,9 +175,9 @@
186 175 return $connect->get_app( 'library' );
187 176 }
188 177
189 178 public static function should_show_pro_install_screen(): bool {
190 - if ( self::is_elementor_pro_installed() ) {
179 + if ( Utils::has_pro() || Utils::is_pro_installed_and_not_active() ) {
191 180 return false;
192 181 }
193 182
194 183 $connect = Plugin::$instance->common->get_component( 'connect' );
@@ -227,30 +216,8 @@
227 216
228 217 return $user->first_name ?? '';
229 218 }
230 219
231 - public function should_show_starter(): bool {
232 - $progress = $this->progress_manager->get_progress();
233 -
234 - return self::VERSION === get_option( self::ONBOARDING_OPTION ) && ! $progress->is_starter_dismissed();
235 - }
236 -
237 - public function add_starter_packages( array $packages ): array {
238 - $packages[] = 'editor-starter';
239 -
240 - return $packages;
241 - }
242 -
243 - public function add_starter_settings( array $settings ): array {
244 - $settings['starter'] = [
245 - 'restPath' => 'elementor/v1/onboarding/user-progress',
246 - 'aiPlannerUrl' => 'https://planner.elementor.com/home.html',
247 - 'kitLibraryUrl' => Plugin::$instance->app->get_base_url() . '#/kit-library',
248 - ];
249 -
250 - return $settings;
251 - }
252 -
253 220 private function maybe_invalidate_theme_selection( User_Progress $progress, User_Choices $choices ): void {
254 221 $selected_theme = $choices->get_theme_selection();
255 222
256 223 if ( empty( $selected_theme ) ) {
@@ -311,32 +278,14 @@
311 278
312 279 private function get_steps_config(): array {
313 280 $steps = [
314 281 [
315 - 'id' => 'building_for',
316 - 'label' => __( 'Who are you building for?', 'elementor' ),
282 + 'id' => 'theme_selection',
283 + 'label' => __( 'Start with a theme that fits your needs', 'elementor' ),
317 284 'type' => 'single',
318 285 ],
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 286 ];
330 287
331 - if ( ! $this->is_elementor_theme_active() ) {
332 - $steps[] = [
333 - 'id' => 'theme_selection',
334 - 'label' => __( 'Start with a theme that fits your needs', 'elementor' ),
335 - 'type' => 'single',
336 - ];
337 - }
338 -
339 288 if ( ! self::is_elementor_pro_installed() ) {
340 289 $steps[] = [
341 290 'id' => 'site_features',
342 291 'label' => __( 'What do you want to include in your site?', 'elementor' ),
@@ -347,15 +296,17 @@
347 296 return apply_filters( 'elementor/onboarding/steps', $steps );
348 297 }
349 298
350 299 private static function is_elementor_pro_installed(): bool {
351 - $is_pro_installed = Utils::has_pro() || Utils::is_pro_installed_and_not_active();
300 + $is_pro_installed = Utils::has_pro();
352 301 return (bool) apply_filters( 'elementor/onboarding/is_elementor_pro_installed', $is_pro_installed );
353 302 }
354 303
355 - private function is_elementor_theme_active(): bool {
304 + private function is_hello_theme_active(): bool {
356 305 $active_theme = get_stylesheet();
357 - $is_active = in_array( $active_theme, Install_Theme::ALLOWED_THEMES, true );
306 + $is_active = 0 === strpos( $active_theme, 'hello-' );
307 +
308 + $is_active = (bool) apply_filters( 'elementor/onboarding/is_hello_theme_active', $is_active );
358 309
359 310 return (bool) apply_filters( 'elementor/onboarding/is_elementor_theme_active', $is_active );
360 311 }
361 312 }