Onboarding: Redirect the user to the task list if referer is wccom checkout (https://github.com/woocommerce/woocommerce-admin/pull/3495)
This commit is contained in:
parent
da0844c53e
commit
a2bff95a4a
|
@ -86,6 +86,7 @@ class Onboarding {
|
||||||
add_action( 'current_screen', array( $this, 'reset_profiler' ) );
|
add_action( 'current_screen', array( $this, 'reset_profiler' ) );
|
||||||
add_action( 'current_screen', array( $this, 'reset_task_list' ) );
|
add_action( 'current_screen', array( $this, 'reset_task_list' ) );
|
||||||
add_action( 'current_screen', array( $this, 'calypso_tests' ) );
|
add_action( 'current_screen', array( $this, 'calypso_tests' ) );
|
||||||
|
add_action( 'current_screen', array( $this, 'redirect_wccom_install' ) );
|
||||||
add_filter( 'woocommerce_admin_is_loading', array( $this, 'is_loading' ) );
|
add_filter( 'woocommerce_admin_is_loading', array( $this, 'is_loading' ) );
|
||||||
add_filter( 'woocommerce_show_admin_notice', array( $this, 'remove_install_notice' ), 10, 2 );
|
add_filter( 'woocommerce_show_admin_notice', array( $this, 'remove_install_notice' ), 10, 2 );
|
||||||
}
|
}
|
||||||
|
@ -898,4 +899,21 @@ class Onboarding {
|
||||||
|
|
||||||
return $show;
|
return $show;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects the user to the task list if the task list is enabled and finishing a wccom checkout.
|
||||||
|
*
|
||||||
|
* @todo Once URL params are added to the redirect, we can check those instead of the referer.
|
||||||
|
*/
|
||||||
|
public static function redirect_wccom_install() {
|
||||||
|
if (
|
||||||
|
! self::should_show_tasks() ||
|
||||||
|
! isset( $_SERVER['HTTP_REFERER'] ) ||
|
||||||
|
0 !== strpos( $_SERVER['HTTP_REFERER'], 'https://woocommerce.com/checkout' ) // phpcs:ignore sanitization ok.
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_safe_redirect( wc_admin_url() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue