wpsc_remove_tracking_params_from_uri()WPSCache 1.0

No Hooks.

Return

null. Nothing.

Usage

wpsc_remove_tracking_params_from_uri( $uri );
$uri (required)
-

Code of wpsc_remove_tracking_params_from_uri() WPSCache 1.8

function wpsc_remove_tracking_params_from_uri( $uri ) {
	global $wpsc_tracking_parameters, $wpsc_ignore_tracking_parameters;

	if ( ! isset( $wpsc_ignore_tracking_parameters ) || ! $wpsc_ignore_tracking_parameters ) {
		return $uri;
	}

	if ( ! isset( $wpsc_tracking_parameters ) || empty( $wpsc_tracking_parameters ) ) {
		return $uri;
	}

	$parsed_url = parse_url( $uri );
	$query      = array();

	if ( isset( $parsed_url['query'] ) ) {
		parse_str( $parsed_url['query'], $query );
		foreach ( $wpsc_tracking_parameters as $param_name ) {
			unset( $query[ $param_name ] );
			unset( $_GET[ $param_name ] );
		}
	}
	$path  = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '';
	$query = ! empty( $query ) ? '?' . http_build_query( $query ) : '';

	if ( empty( $_GET ) ) {
		$_SERVER['REQUEST_URI'] = strtok( $_SERVER['REQUEST_URI'], '?' );
	}

	if ( $uri !== $path . $query ) {
		wp_cache_debug( 'Removed tracking parameters from URL. Returning ' . $path . $query );
	}

	return $path . $query;
}