Skip to content

Commit 71ed2bd

Browse files
committed
feat(onboarding): support TI_ONBOARDING_DEFAULT_SITE redirect
When the TI_ONBOARDING_DEFAULT_SITE constant is defined, the post-activation redirect now lands on the preview/import screen for that site (admin.php?page=neve-onboarding&site=<slug>) instead of the default search/welcome screen. The onboarding store resolves the ?site=<slug> query param against the bootstrapped sites list (across all builders) and starts at step 3 with currentSite preset; if the slug is unknown the app falls back to the existing search screen. This lets distributions and embedded environments (e.g. WordPress Playground) deep-link a user straight to the import flow for a chosen starter site. Made-with: Cursor
1 parent 9087799 commit 71ed2bd

2 files changed

Lines changed: 29 additions & 11 deletions

File tree

includes/Admin.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,16 @@ public function activation_redirect() {
398398
}
399399

400400
delete_option( 'tpc_maybe_run_onboarding' );
401-
wp_safe_redirect(
402-
add_query_arg(
403-
array(
404-
'page' => 'neve-onboarding',
405-
'show' => 'welcome',
406-
),
407-
admin_url( 'admin.php' )
408-
)
409-
);
401+
402+
$query_args = array( 'page' => 'neve-onboarding' );
403+
404+
if ( defined( 'TI_ONBOARDING_DEFAULT_SITE' ) && TI_ONBOARDING_DEFAULT_SITE ) {
405+
$query_args['site'] = sanitize_key( TI_ONBOARDING_DEFAULT_SITE );
406+
} else {
407+
$query_args['show'] = 'welcome';
408+
}
409+
410+
wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) );
410411
exit();
411412
}
412413

onboarding/src/store/reducer.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,32 @@ const initialLicense = licenseTIOB || {
1616
tier: 0,
1717
};
1818

19+
const params = new URLSearchParams( window.location.search );
20+
const defaultSiteSlug = params.get( 'site' );
21+
22+
const findSiteBySlug = ( slug ) => {
23+
const builders = onboarding?.sites?.sites || {};
24+
for ( const builder of Object.keys( builders ) ) {
25+
if ( builders[ builder ]?.[ slug ] ) {
26+
return builders[ builder ][ slug ];
27+
}
28+
}
29+
return null;
30+
};
31+
32+
const defaultSite = defaultSiteSlug ? findSiteBySlug( defaultSiteSlug ) : null;
33+
1934
const initialState = {
2035
sites: onboarding.sites || {},
2136
editor: selectedEditor,
2237
category: '',
23-
currentSite: null,
38+
currentSite: defaultSite,
2439
fetching: false,
2540
searchQuery: '',
2641
license: initialLicense,
27-
onboardingStep: window.location.search.includes('show=welcome') ? 1 : 2,
42+
onboardingStep: defaultSite
43+
? 3
44+
: ( window.location.search.includes('show=welcome') ? 1 : 2 ),
2845
userCustomSettings: {
2946
siteName: null,
3047
siteLogo: null,

0 commit comments

Comments
 (0)