Onboarding: Mark profiler complete on WC update (https://github.com/woocommerce/woocommerce-admin/pull/3590)

* Mark profiler as complete if previous onboarding install has been handled

* Load features before WC updated hooks

* Add todo note about updating core install check
This commit is contained in:
Joshua T Flowers 2020-01-29 22:47:04 +08:00 committed by GitHub
parent 761a67f18b
commit 243901a38f
2 changed files with 26 additions and 1 deletions

View File

@ -63,6 +63,7 @@ class Onboarding {
// Adds the ability to toggle the new onboarding experience on or off.
// @todo This option should be removed when merging the onboarding feature to core.
add_action( 'current_screen', array( $this, 'enable_onboarding' ) );
add_action( 'woocommerce_updated', array( $this, 'maybe_mark_complete' ) );
if ( ! Loader::is_onboarding_enabled() ) {
add_action( 'current_screen', array( $this, 'update_help_tab' ), 60 );
@ -938,4 +939,27 @@ class Onboarding {
wp_safe_redirect( wc_admin_url() );
}
/**
* When updating WooCommerce, mark the profiler and task list complete.
*
* @todo The `maybe_enable_setup_wizard()` method should be revamped on onboarding enable in core.
* See https://github.com/woocommerce/woocommerce/blob/1ca791f8f2325fe2ee0947b9c47e6a4627366374/includes/class-wc-install.php#L341
*/
public static function maybe_mark_complete() {
// The install notice still exists so don't complete the profiler.
if ( ! class_exists( 'WC_Admin_Notices' ) || \WC_Admin_Notices::has_notice( 'install' ) ) {
return;
}
$onboarding_data = get_option( self::PROFILE_DATA_OPTION, array() );
// Don't make updates if the profiler is completed, but task list is potentially incomplete.
if ( isset( $onboarding_data['completed'] ) && $onboarding_data['completed'] ) {
return;
}
$onboarding_data['completed'] = true;
update_option( self::PROFILE_DATA_OPTION, $onboarding_data );
update_option( 'woocommerce_task_list_hidden', 'yes' );
}
}

View File

@ -57,7 +57,8 @@ class Loader {
*/
public function __construct() {
add_action( 'init', array( __CLASS__, 'define_tables' ) );
add_action( 'init', array( __CLASS__, 'load_features' ) );
// Load feature before WooCommerce update hooks.
add_action( 'init', array( __CLASS__, 'load_features' ), 4 );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'register_scripts' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'inject_wc_settings_dependencies' ), 14 );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_scripts' ), 15 );