From 994b09a1737ec0d260e4df566066c6c7d53985c0 Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Thu, 9 Jan 2025 15:20:49 +0200 Subject: [PATCH 1/2] refactor: use only the onboarding workflow to selecting a starter site --- includes/Admin.php | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/includes/Admin.php b/includes/Admin.php index 4af61a61..6befbf83 100755 --- a/includes/Admin.php +++ b/includes/Admin.php @@ -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' ) ); @@ -514,10 +513,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 ) { @@ -528,12 +523,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', ), ); @@ -553,25 +548,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. * @@ -636,10 +612,6 @@ 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; } From 511e26b2598489995801da263ea1065a03f3b07f Mon Sep 17 00:00:00 2001 From: "Soare Robert Daniel (Mac 2023)" Date: Fri, 10 Jan 2025 11:24:43 +0200 Subject: [PATCH 2/2] refactor: show site list as first step unless the user is first time --- includes/Admin.php | 24 ++++++++++-------------- onboarding/src/store/reducer.js | 3 ++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/includes/Admin.php b/includes/Admin.php index 6befbf83..f4239b7f 100755 --- a/includes/Admin.php +++ b/includes/Admin.php @@ -397,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(); } @@ -619,18 +627,6 @@ public function register_legacy_template_cloud_pages() { $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. * @@ -710,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(); diff --git a/onboarding/src/store/reducer.js b/onboarding/src/store/reducer.js index d9a9b61b..9699ebfa 100644 --- a/onboarding/src/store/reducer.js +++ b/onboarding/src/store/reducer.js @@ -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, @@ -35,6 +35,7 @@ const initialState = { trackingId: '', refresh: false, }; + export default ( state = initialState, action ) => { switch ( action.type ) { case 'SET_CATEGORY':