Automattic\WooCommerce\Admin

PluginsInstaller::redirect_to_referer()public staticWC 1.0

Redirect back to the referring page if one exists.

Method of the class: PluginsInstaller{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = PluginsInstaller::redirect_to_referer();

PluginsInstaller::redirect_to_referer() code WC 9.3.3

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();
}