d to access the setup wizard again, please click on the button below.', 'woocommerce' ) . '
' . '' . __( 'Setup wizard', 'woocommerce' ) . '
'; $help_tab['content'] .= '' . __( 'If you need to enable or disable the task lists, please click on the button below.', 'woocommerce' ) . '
' . ( $task_list_hidden ? '' . __( 'Enable', 'woocommerce' ) . '
' : '' . __( 'Disable', 'woocommerce' ) . '
' ); $help_tab['content'] .= '' . __( 'If you need to enable or disable the extended task lists, please click on the button below.', 'woocommerce' ) . '
' . ( $extended_task_list_hidden ? '' : '' ); $screen->add_help_tab( $help_tab ); } /** * Reset the onboarding profiler and redirect to the profiler. */ public static function reset_profiler() { if ( ! Loader::is_admin_page() || ! isset( $_GET['reset_profiler'] ) // phpcs:ignore CSRF ok. ) { return; } $previous = 1 === absint( $_GET['reset_profiler'] ); // phpcs:ignore CSRF ok. $new_value = ! $previous; wc_admin_record_tracks_event( 'storeprofiler_toggled', array( 'previous' => $previous, 'new_value' => $new_value, ) ); $request = new \WP_REST_Request( 'POST', '/wc-admin/onboarding/profile' ); $request->set_headers( array( 'content-type' => 'application/json' ) ); $request->set_body( wp_json_encode( array( 'completed' => $new_value, 'skipped' => $new_value, ) ) ); $response = rest_do_request( $request ); wp_safe_redirect( wc_admin_url() ); exit; } /** * Reset the onboarding task list and redirect to the dashboard. */ public static function reset_task_list() { if ( ! Loader::is_admin_page() || ! isset( $_GET['reset_task_list'] ) // phpcs:ignore CSRF ok. ) { return; } $task_list_hidden = 1 === absint( $_GET['reset_task_list'] ) ? 'no' : 'yes'; // phpcs:ignore CSRF ok. update_option( 'woocommerce_task_list_hidden', $task_list_hidden ); wc_admin_record_tracks_event( 'tasklist_toggled', array( 'status' => 'yes' === $task_list_hidden ? 'disabled' : 'enabled', ) ); wp_safe_redirect( wc_admin_url() ); exit; } /** * Reset the extended task list and redirect to the dashboard. */ public static function reset_extended_task_list() { if ( ! Loader::is_admin_page() || ! isset( $_GET['reset_extended_task_list'] ) // phpcs:ignore CSRF ok. ) { return; } $extended_task_list_hidden = 1 === absint( $_GET['reset_extended_task_list'] ) ? 'no' : 'yes'; // phpcs:ignore CSRF ok. update_option( 'woocommerce_extended_task_list_hidden', $extended_task_list_hidden ); wc_admin_record_tracks_event( 'extended_tasklist_toggled', array( 'status' => 'yes' === $extended_task_list_hidden ? 'disabled' : 'enabled', ) ); wp_safe_redirect( wc_admin_url() ); exit; } /** * Remove the install notice that prompts the user to visit the old onboarding setup wizard. * * @param bool $show Show or hide the notice. * @param string $notice The slug of the notice. * @return bool */ public static function remove_install_notice( $show, $notice ) { if ( 'install' === $notice ) { return false; } 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() ); } /** * 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' ); } }