Skip to content

Commit f8c392e

Browse files
committed
saving site info in options table
1 parent cdb2c1f commit f8c392e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

includes/Services/AppService.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use NewfoldLabs\WP\Module\Onboarding\Data\Options;
77
use NewfoldLabs\WP\Module\Onboarding\Data\Services\PreviewsService;
88
use NewfoldLabs\WP\Module\Onboarding\Data\Services\SiteGenService as LegacySiteGenService;
9+
use NewfoldLabs\WP\Module\Onboarding\Data\Services\FlowService;
910

1011

1112
use function NewfoldLabs\WP\ModuleLoader\container;
@@ -59,6 +60,9 @@ public function complete( string $selected_sitegen_homepage ): void {
5960
// Mark onboarding as completed.
6061
StatusService::handle_completed();
6162

63+
// Save onboarding site information for other modules to access.
64+
SiteInfoService::save_site_info();
65+
6266
// Purge all caches.
6367
container()->get( 'cachePurger' )->purge_all();
6468

includes/Services/SiteInfoService.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace NewfoldLabs\WP\Module\Onboarding\Services;
4+
5+
use NewfoldLabs\WP\Module\Onboarding\Data\Services\FlowService;
6+
7+
/**
8+
* Service for handling onboarding site information persistence and retrieval.
9+
*/
10+
class SiteInfoService {
11+
12+
/**
13+
* Database option name for storing onboarding site information.
14+
*/
15+
const SITE_INFO_OPTION = 'nfd_module_onboarding_site_info';
16+
17+
/**
18+
* Save onboarding site information to database option for other modules to access.
19+
*
20+
* @return void
21+
*/
22+
public static function save_site_info(): void {
23+
$site_info = array();
24+
25+
// Get experience level from FlowService
26+
$experience_level = FlowService::get_experience_level();
27+
$site_info['experience_level'] = $experience_level;
28+
29+
// Get site type from flow data
30+
$flow_data = FlowService::read_data_from_wp_option( false );
31+
if ( $flow_data && isset( $flow_data['data']['siteType']['primary']['value'] ) ) {
32+
$site_info['site_type'] = $flow_data['data']['siteType']['primary']['value'];
33+
} else {
34+
// Fallback to default site type
35+
$site_info['site_type'] = 'business';
36+
}
37+
38+
// Save to database option
39+
update_option( self::SITE_INFO_OPTION, $site_info );
40+
}
41+
42+
/**
43+
* Get the stored onboarding site information.
44+
*
45+
* @return array
46+
*/
47+
public static function get_site_info(): array {
48+
return get_option( self::SITE_INFO_OPTION, array() );
49+
}
50+
51+
/**
52+
* Delete the stored onboarding site information.
53+
*
54+
* @return bool
55+
*/
56+
public static function delete_site_info(): bool {
57+
return delete_option( self::SITE_INFO_OPTION );
58+
}
59+
}

0 commit comments

Comments
 (0)