Automattic\WooCommerce\Admin

PluginsInstaller::redirect_to_referer()public staticWC 1.0

Redirect back to the referring page if one exists.

{} It's a method of the class: PluginsInstaller{}

No Hooks.

Return

null. Nothing.

Usage

$result = PluginsInstaller::redirect_to_referer();

Code of PluginsInstaller::redirect_to_referer() WC 7.1.0

public static function redirect_to_referer() {
	$referer = wp_get_referer();
	if ( $referer && 0 !== strpos( $referer, wp_login_url() ) ) {
		wp_safe_redirect( $referer );
		exit();
	}

	if ( ! isset( $_SERVER['REQUEST_URI'] ) ) {
		return;
	}

	$url = remove_query_arg( 'plugin_action', wp_unslash( $_SERVER['REQUEST_URI'] ) ); // phpcs:ignore sanitization ok.
	$url = remove_query_arg( 'plugins', $url );
	wp_safe_redirect( $url );
	exit();
}