WC_Admin::admin_redirects()
Handle redirects to setup/welcome page after install and updates.
Description Description
The user must have access rights, and we must ignore the network/bulk plugin updaters.
Source Source
File: includes/admin/class-wc-admin.php
public function admin_redirects() { // Don't run this fn from Action Scheduler requests, as it would clear _wc_activation_redirect transient. // That means OBW would never be shown. if ( wc_is_running_from_async_action_scheduler() ) { return; } // phpcs:disable WordPress.Security.NonceVerification.Recommended // Nonced plugin install redirects (whitelisted). if ( ! empty( $_GET['wc-install-plugin-redirect'] ) ) { $plugin_slug = wc_clean( wp_unslash( $_GET['wc-install-plugin-redirect'] ) ); if ( current_user_can( 'install_plugins' ) && in_array( $plugin_slug, array( 'woocommerce-gateway-stripe' ), true ) ) { $nonce = wp_create_nonce( 'install-plugin_' . $plugin_slug ); $url = self_admin_url( 'update.php?action=install-plugin&plugin=' . $plugin_slug . '&_wpnonce=' . $nonce ); } else { $url = admin_url( 'plugin-install.php?tab=search&type=term&s=' . $plugin_slug ); } wp_safe_redirect( $url ); exit; } // Setup wizard redirect. if ( get_transient( '_wc_activation_redirect' ) && apply_filters( 'woocommerce_enable_setup_wizard', true ) ) { $do_redirect = true; $current_page = isset( $_GET['page'] ) ? wc_clean( wp_unslash( $_GET['page'] ) ) : false; // On these pages, or during these events, postpone the redirect. if ( wp_doing_ajax() || is_network_admin() || ! current_user_can( 'manage_woocommerce' ) ) { $do_redirect = false; } // On these pages, or during these events, disable the redirect. if ( 'wc-setup' === $current_page || ! WC_Admin_Notices::has_notice( 'install' ) || apply_filters( 'woocommerce_prevent_automatic_wizard_redirect', false ) || isset( $_GET['activate-multi'] ) ) { delete_transient( '_wc_activation_redirect' ); $do_redirect = false; } if ( $do_redirect ) { delete_transient( '_wc_activation_redirect' ); wp_safe_redirect( admin_url( 'index.php?page=wc-setup' ) ); exit; } } // phpcs:enable WordPress.Security.NonceVerification.Recommended }