sk_list'] ) // phpcs:ignore CSRF ok. ) { return; } $task_list = TaskLists::get_list( 'setup' ); if ( ! $task_list ) { return; } $show = 1 === absint( $_GET['reset_task_list'] ); $update = $show ? $task_list->unhide() : $task_list->hide(); // phpcs:ignore CSRF ok. if ( $update ) { wc_admin_record_tracks_event( 'tasklist_toggled', array( 'status' => $show ? 'enabled' : 'disabled', ) ); } 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; } $task_list = TaskLists::get_list( 'extended' ); if ( ! $task_list ) { return; } $show = 1 === absint( $_GET['reset_extended_task_list'] ); $update = $show ? $task_list->unhide() : $task_list->hide(); // phpcs:ignore CSRF ok. if ( $update ) { wc_admin_record_tracks_event( 'extended_tasklist_toggled', array( 'status' => $show ? '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() { $task_list = TaskLists::get_list( 'setup' ); if ( ! $task_list || $task_list->is_hidden() || ! isset( $_SERVER['HTTP_REFERER'] ) || 0 !== strpos( $_SERVER['HTTP_REFERER'], 'https://woocommerce.com/checkout?utm_medium=product' ) // 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 or skipped, but task list is potentially incomplete. if ( ( isset( $onboarding_data['completed'] ) && $onboarding_data['completed'] ) || ( isset( $onboarding_data['skipped'] ) && $onboarding_data['skipped'] ) ) { return; } $onboarding_data['completed'] = true; update_option( self::PROFILE_DATA_OPTION, $onboarding_data ); if ( ! WCAdminHelper::is_wc_admin_active_for( DAY_IN_SECONDS ) ) { $task_list = TaskLists::get_list( 'setup' ); if ( ! $task_list ) { return; } $task_list->hide(); } } /** * Ensure that Jetpack gets installed and activated ahead of WooCommerce Payments * if both are being installed/activated at the same time. * * See: https://github.com/Automattic/woocommerce-payments/issues/1663 * See: https://github.com/Automattic/jetpack/issues/19624 * * @param array $plugins A list of plugins to install or activate. * * @return array */ public static function activate_and_install_jetpack_ahead_of_wcpay( $plugins ) { if ( in_array( 'jetpack', $plugins, true ) && in_array( 'woocommerce-payments', $plugins, true ) ) { array_unshift( $plugins, 'jetpack' ); $plugins = array_unique( $plugins ); } return $plugins; } /** * Delete MailchimpScheduler::SUBSCRIBED_OPTION_NAME option if profile data is being updated with a new email. * * @param array $existing_data Existing option data. * @param array $updating_data Updating option data. */ public function on_profile_data_updated( $existing_data, $updating_data ) { if ( isset( $existing_data['store_email'] ) && isset( $updating_data['store_email'] ) && $existing_data['store_email'] !== $updating_data['store_email'] ) { delete_option( MailchimpScheduler::SUBSCRIBED_OPTION_NAME ); } } }