From b0b79e89680ae83b9cd766f4a9df802fa800a699 Mon Sep 17 00:00:00 2001 From: Joshua T Flowers Date: Tue, 21 Jan 2020 20:05:10 +0800 Subject: [PATCH] Redirect old onboarding wizard to profiler when active (https://github.com/woocommerce/woocommerce-admin/pull/3593) --- .../woocommerce-admin/src/Features/Onboarding.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/woocommerce-admin/src/Features/Onboarding.php b/plugins/woocommerce-admin/src/Features/Onboarding.php index 70dadf7eb84..d4ba89c1fe5 100644 --- a/plugins/woocommerce-admin/src/Features/Onboarding.php +++ b/plugins/woocommerce-admin/src/Features/Onboarding.php @@ -101,10 +101,23 @@ class Onboarding { add_action( 'current_screen', array( $this, 'reset_task_list' ) ); add_action( 'current_screen', array( $this, 'calypso_tests' ) ); add_action( 'current_screen', array( $this, 'redirect_wccom_install' ) ); + add_action( 'current_screen', array( $this, 'redirect_old_onboarding' ) ); add_filter( 'woocommerce_admin_is_loading', array( $this, 'is_loading' ) ); add_filter( 'woocommerce_show_admin_notice', array( $this, 'remove_install_notice' ), 10, 2 ); } + /** + * Redirect the old onboarding wizard to the profiler. + */ + public static function redirect_old_onboarding() { + $current_page = isset( $_GET['page'] ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : false; // phpcs:ignore csrf okay. + + if ( 'wc-setup' === $current_page ) { + delete_transient( '_wc_activation_redirect' ); + wp_safe_redirect( wc_admin_url() ); + } + } + /** * Returns true if the profiler should be displayed (not completed). *