7
7
use NewfoldLabs \WP \Module \Onboarding \Data \Services \PreviewsService ;
8
8
use NewfoldLabs \WP \Module \Onboarding \Data \Services \SiteGenService as LegacySiteGenService ;
9
9
10
-
11
10
use function NewfoldLabs \WP \ModuleLoader \container ;
12
11
12
+ /**
13
+ * App Service for handling onboarding application lifecycle.
14
+ *
15
+ * This service manages the start and completion of the onboarding process,
16
+ * including initialization of required services, publishing selected content,
17
+ * and saving site information for other modules to access.
18
+ */
13
19
class AppService {
14
20
15
21
/**
@@ -45,13 +51,13 @@ public function start(): void {
45
51
*
46
52
* @param string $selected_sitegen_homepage The selected sitegen homepage to publish.
47
53
* @return void
48
- * @throws \Exception
54
+ * @throws \Exception When homepage publishing fails.
49
55
*/
50
56
public function complete ( string $ selected_sitegen_homepage ): void {
51
57
// Publish selected homepage.
52
58
$ result = ( new SiteGenService () )->publish_homepage ( $ selected_sitegen_homepage );
53
59
if ( \is_wp_error ( $ result ) ) {
54
- throw new \Exception ( $ result ->get_error_message () );
60
+ throw new \Exception ( esc_html ( $ result ->get_error_message () ) );
55
61
}
56
62
// Trash Preview pages.
57
63
PreviewsService::trash_preview_pages ();
@@ -69,8 +75,8 @@ public function complete( string $selected_sitegen_homepage ): void {
69
75
array (
70
76
'label_key ' => 'value ' ,
71
77
),
72
- __ ( 'Help us improve ' , 'wp-module-onboarding-data ' ),
73
- __ ( 'How satisfied were you with the ease of creating your website? ' , 'wp-module-onboarding-data ' ),
78
+ __ ( 'Help us improve ' , 'wp-module-onboarding ' ),
79
+ __ ( 'How satisfied were you with the ease of creating your website? ' , 'wp-module-onboarding ' ),
74
80
);
75
81
}
76
82
}
0 commit comments