PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0-dev4
Elementor Website Builder – more than just a page builder v4.0.0-dev4
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 4.0.8 All 454 releases
← All changes | app/modules/onboarding/module.php +69 -22 4.3.0-beta24.0.0-dev4 View file →
@@ -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;
@@ -50,8 +51,15 @@
50 51
51 52 Plugin::instance()->data_manager_v2->register_controller( new Controller() );
52 53
53 54 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 + }
54 62 }
55 63
56 64 public function on_elementor_init(): void {
57 65 if ( ! Plugin::instance()->app->is_current() ) {
@@ -70,8 +78,19 @@
70 78 ELEMENTOR_VERSION
71 79 );
72 80 }
73 81
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 +
74 93 public function progress_manager(): Onboarding_Progress_Manager {
75 94 return $this->progress_manager;
76 95 }
77 96
@@ -102,14 +121,12 @@
102 121 'steps' => $steps,
103 122 'uiTheme' => $this->get_ui_theme_preference(),
104 123 'translations' => $this->get_translated_strings(),
105 124 'shouldShowProInstallScreen' => $is_connected ? $this->should_show_pro_install_screen() : false,
106 - 'isHelloThemeActive' => $this->is_hello_theme_active(),
107 125 'urls' => [
108 126 'dashboard' => admin_url(),
109 127 'editor' => admin_url( 'edit.php?post_type=elementor_library' ),
110 128 'connect' => $this->get_connect_url(),
111 - 'signUp' => $this->get_connect_url( 'signup' ),
112 129 'comparePlans' => 'https://go.elementor.com/go-pro-onboarding-editor-features-step-upgrade/',
113 130 'createNewPage' => Plugin::$instance->documents->get_create_new_post_url(),
114 131 'upgradeUrl' => 'https://go.elementor.com/go-pro-onboarding-editor-header-upgrade/',
115 132 ],
@@ -117,28 +134,21 @@
117 134 }
118 135
119 136 private function validate_progress_for_steps( User_Progress $progress, array $steps ): array {
120 137 $progress_data = $progress->to_array();
121 - $step_ids = array_column( $steps, 'id' );
122 138 $step_count = count( $steps );
123 - $fallback_step_id = $steps[0]['id'] ?? 'site_features';
124 139 $current_step_index = $progress->get_current_step_index() ?? 0;
125 - $current_step_id = $progress->get_current_step_id() ?? $fallback_step_id;
140 + $current_step_id = $progress->get_current_step_id() ?? $steps[0]['id'] ?? 'building_for';
126 141
127 142 $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 );
129 143
130 - if ( $is_invalid_step_index || $is_invalid_step_id ) {
131 - $current_step_id = $fallback_step_id;
144 + if ( $is_invalid_step_index ) {
145 + $current_step_id = $steps[0]['id'];
132 146 $current_step_index = 0;
133 147 }
134 148
135 149 $progress_data['current_step_id'] = $current_step_id;
136 150 $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 - ) );
141 151
142 152 return $progress_data;
143 153 }
144 154
@@ -147,9 +157,9 @@
147 157
148 158 return $library ? $library->is_connected() : false;
149 159 }
150 160
151 - private function get_connect_url( string $screen_hint = '' ): string {
161 + private function get_connect_url(): string {
152 162 $library = $this->get_library_app();
153 163
154 164 if ( ! $library ) {
155 165 return '';
@@ -160,9 +170,8 @@
160 170 'utm_campaign' => 'connect-account',
161 171 'utm_medium' => 'wp-dash',
162 172 'utm_term' => self::VERSION,
163 173 'source' => 'generic',
164 - 'screen_hint' => $screen_hint,
165 174 ] ) ?? '';
166 175 }
167 176
168 177 private function get_library_app() {
@@ -175,9 +184,9 @@
175 184 return $connect->get_app( 'library' );
176 185 }
177 186
178 187 public static function should_show_pro_install_screen(): bool {
179 - if ( Utils::has_pro() || Utils::is_pro_installed_and_not_active() ) {
188 + if ( self::is_elementor_pro_installed() ) {
180 189 return false;
181 190 }
182 191
183 192 $connect = Plugin::$instance->common->get_component( 'connect' );
@@ -216,8 +225,30 @@
216 225
217 226 return $user->first_name ?? '';
218 227 }
219 228
229 + public function should_show_starter(): bool {
230 + $progress = $this->progress_manager->get_progress();
231 +
232 + return self::VERSION === get_option( self::ONBOARDING_OPTION ) && ! $progress->is_starter_dismissed();
233 + }
234 +
235 + public function add_starter_packages( array $packages ): array {
236 + $packages[] = 'editor-starter';
237 +
238 + return $packages;
239 + }
240 +
241 + public function add_starter_settings( array $settings ): array {
242 + $settings['starter'] = [
243 + 'restPath' => 'elementor/v1/onboarding/user-progress',
244 + 'aiPlannerUrl' => 'https://planner.elementor.com/home.html',
245 + 'kitLibraryUrl' => Plugin::$instance->app->get_base_url() . '#/kit-library',
246 + ];
247 +
248 + return $settings;
249 + }
250 +
220 251 private function maybe_invalidate_theme_selection( User_Progress $progress, User_Choices $choices ): void {
221 252 $selected_theme = $choices->get_theme_selection();
222 253
223 254 if ( empty( $selected_theme ) ) {
@@ -278,13 +309,31 @@
278 309
279 310 private function get_steps_config(): array {
280 311 $steps = [
281 312 [
313 + 'id' => 'building_for',
314 + 'label' => __( 'Who are you building for?', 'elementor' ),
315 + 'type' => 'single',
316 + ],
317 + [
318 + 'id' => 'site_about',
319 + 'label' => __( 'What is your site about?', 'elementor' ),
320 + 'type' => 'multiple',
321 + ],
322 + [
323 + 'id' => 'experience_level',
324 + 'label' => __( 'How much experience do you have with Elementor?', 'elementor' ),
325 + 'type' => 'single',
326 + ],
327 + ];
328 +
329 + if ( ! $this->is_elementor_theme_active() ) {
330 + $steps[] = [
282 331 'id' => 'theme_selection',
283 332 'label' => __( 'Start with a theme that fits your needs', 'elementor' ),
284 333 'type' => 'single',
285 - ],
286 - ];
334 + ];
335 + }
287 336
288 337 if ( ! self::is_elementor_pro_installed() ) {
289 338 $steps[] = [
290 339 'id' => 'site_features',
@@ -296,17 +345,15 @@
296 345 return apply_filters( 'elementor/onboarding/steps', $steps );
297 346 }
298 347
299 348 private static function is_elementor_pro_installed(): bool {
300 - $is_pro_installed = Utils::has_pro();
349 + $is_pro_installed = Utils::has_pro() || Utils::is_pro_installed_and_not_active();
301 350 return (bool) apply_filters( 'elementor/onboarding/is_elementor_pro_installed', $is_pro_installed );
302 351 }
303 352
304 - private function is_hello_theme_active(): bool {
353 + private function is_elementor_theme_active(): bool {
305 354 $active_theme = get_stylesheet();
306 - $is_active = 0 === strpos( $active_theme, 'hello-' );
307 -
308 - $is_active = (bool) apply_filters( 'elementor/onboarding/is_hello_theme_active', $is_active );
355 + $is_active = in_array( $active_theme, Install_Theme::ALLOWED_THEMES, true );
309 356
310 357 return (bool) apply_filters( 'elementor/onboarding/is_elementor_theme_active', $is_active );
311 358 }
312 359 }