File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,9 @@ public function complete( string $selected_sitegen_homepage ): void {
56
56
// Trash Preview pages.
57
57
PreviewsService::trash_preview_pages ();
58
58
59
+ // Mark onboarding as completed.
60
+ StatusService::handle_completed ();
61
+
59
62
// Purge all caches.
60
63
container ()->get ( 'cachePurger ' )->purge_all ();
61
64
Original file line number Diff line number Diff line change @@ -28,6 +28,17 @@ public static function handle_started(): bool {
28
28
return false ;
29
29
}
30
30
31
+ /**
32
+ * Handles Onboarding abandoned event.
33
+ *
34
+ * @return void
35
+ */
36
+ public static function handle_abandoned (): void {
37
+ if ( 'started ' === get_option ( Options::get_option_name ( 'status ' ) ) ) {
38
+ update_option ( Options::get_option_name ( 'status ' ), 'abandoned ' );
39
+ }
40
+ }
41
+
31
42
/**
32
43
* Handles Onboarding completed event.
33
44
*
@@ -164,22 +175,17 @@ public static function update_onboarding_restart_status(): void {
164
175
* @return void
165
176
*/
166
177
public static function track (): void {
167
- global $ pagenow ;
168
-
178
+ // Ignore if the request is an AJAX request.
169
179
if ( defined ( 'DOING_AJAX ' ) && DOING_AJAX ) {
170
180
return ;
171
181
}
172
182
173
- switch ( $ pagenow ) {
174
- case 'index.php ' :
175
- // If the page is not nfd-onboarding.
176
- //phpcs:ignore
177
- if ( isset ( $ _GET ['page ' ] ) && WP_Admin::$ slug !== \sanitize_text_field ( $ _GET ['page ' ] ) ) {
178
- self ::handle_completed ();
179
- }
180
- break ;
181
- default :
182
- self ::handle_completed ();
183
+ // Ignore if the request is not for the onboarding page.
184
+ if ( isset ( $ _GET ['page ' ] ) && WP_Admin::$ slug === \sanitize_text_field ( $ _GET ['page ' ] ) ) {
185
+ return ;
183
186
}
187
+
188
+ // Handle abandoned event.
189
+ self ::handle_abandoned ();
184
190
}
185
191
}
You can’t perform that action at this time.
0 commit comments