Skip to content

Commit

Permalink
Merge pull request #423 from Codeinwp/refactor/redirect-to-onboarding
Browse files Browse the repository at this point in the history
refactor: use only the onboarding workflow to selecting a starter site
  • Loading branch information
Soare-Robert-Daniel authored Jan 17, 2025
2 parents 3f74571 + 511e26b commit c031132
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 47 deletions.
60 changes: 14 additions & 46 deletions includes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function init() {
add_action( 'after_switch_theme', array( $this, 'get_previous_theme' ) );
add_filter( 'neve_dashboard_page_data', array( $this, 'localize_sites_library' ) );
add_action( 'admin_menu', array( $this, 'register' ) );
add_filter( 'submenu_file', array( $this, 'hide_onboarding' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
add_filter( 'ti_tpc_editor_data', array( $this, 'add_tpc_editor_data' ), 20 );
add_action( 'admin_init', array( $this, 'activation_redirect' ) );
Expand Down Expand Up @@ -398,7 +397,15 @@ public function activation_redirect() {
}

delete_option( 'tpc_maybe_run_onboarding' );
wp_safe_redirect( admin_url( 'admin.php?page=neve-onboarding' ) );
wp_safe_redirect(
add_query_arg(
array(
'page' => 'neve-onboarding',
'show' => 'welcome',
),
admin_url( 'admin.php' )
)
);
exit();
}

Expand Down Expand Up @@ -514,10 +521,6 @@ public function register() {
}

$this->register_starter_sites_page();

if ( $this->should_load_onboarding() ) {
$this->register_onboarding_page();
}
}

private function register_starter_sites_page( $in_appearance = false ) {
Expand All @@ -528,12 +531,12 @@ private function register_starter_sites_page( $in_appearance = false ) {

$starter_site_data = array(
'page_title' => __( 'Starter Sites', 'templates-patterns-collection' ),
'menu_title' => $this->get_prefix_for_menu_item() . __( 'Starter Sites', 'templates-patterns-collection' ),
'capability' => 'activate_plugins',
'menu_slug' => $this->page_slug,
'menu_title' => $this->get_prefix_for_menu_item() . __( 'Onboarding', 'templates-patterns-collection' ),
'capability' => 'install_plugins',
'menu_slug' => 'neve-onboarding',
'callback' => array(
$this,
'render_starter_sites',
'render_onboarding',
),
);

Expand All @@ -553,25 +556,6 @@ private function register_starter_sites_page( $in_appearance = false ) {
$this->add_theme_page_for_tiob( $starter_site_data, 2 );
}

/**
* Registers the onboarding page. Used for Neve onboarding, but hidden in the admin.
*
* @return void
*/
private function register_onboarding_page() {
$onboarding_data = array(
'page_title' => __( 'Onboarding', 'templates-patterns-collection' ),
'menu_title' => $this->get_prefix_for_menu_item() . __( 'Onboarding', 'templates-patterns-collection' ),
'capability' => 'install_plugins',
'menu_slug' => 'neve-onboarding',
'callback' => array(
$this,
'render_onboarding',
),
);
$this->add_theme_page_for_tiob( $onboarding_data, 4 );
}

/**
* Legacy template cloud pages.
*
Expand Down Expand Up @@ -636,29 +620,13 @@ public function register_legacy_template_cloud_pages() {
}
$this->register_starter_sites_page();

if ( $this->should_load_onboarding() ) {
$this->register_onboarding_page();
}

if ( $this->is_library_disabled() ) {
return false;
}
$this->add_subpage_for_tiob( $library_data );
$this->add_subpage_for_tiob( $settings_data );
}

/**
* Hide the onboarding item from Neve menu.
*
* @param $submenu_file string The submenu file.
*
* @return string
*/
public function hide_onboarding( $submenu_file ) {
remove_submenu_page( 'neve-welcome', 'neve-onboarding' );
return $submenu_file;
}

/**
* Map license plan from Neve if available.
*
Expand Down Expand Up @@ -738,7 +706,7 @@ public function enqueue() {
return;
}

if ( $this->should_load_onboarding() && strpos( $screen->id, '_page_neve-onboarding' ) ) {
if ( strpos( $screen->id, '_page_neve-onboarding' ) ) {

wp_enqueue_media();

Expand Down
3 changes: 2 additions & 1 deletion onboarding/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const initialState = {
fetching: false,
searchQuery: '',
license: initialLicense,
onboardingStep: 1,
onboardingStep: window.location.search.includes('show=welcome') ? 1 : 2,
userCustomSettings: {
siteName: null,
siteLogo: null,
Expand All @@ -35,6 +35,7 @@ const initialState = {
trackingId: '',
refresh: false,
};

export default ( state = initialState, action ) => {
switch ( action.type ) {
case 'SET_CATEGORY':
Expand Down

0 comments on commit c031132

Please sign in to comment.