WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Cache_Helper::geolocation_ajax_redirect() public WC 1.0

When using geolocation via ajax, to bust cache, redirect if the location hash does not equal the querystring.

This prevents caching of the wrong data for this request.

Это метод класса: WC_Cache_Helper{}

Хуков нет.

Возвращает

Null. Ничего.

Использование

$result = WC_Cache_Helper::geolocation_ajax_redirect();

Код WC_Cache_Helper::geolocation_ajax_redirect() WC 4.5.2

woocommerce/includes/class-wc-cache-helper.php
<?php
public static function geolocation_ajax_redirect() {
	if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && ! is_checkout() && ! is_cart() && ! is_account_page() && ! is_ajax() && empty( $_POST ) ) { // WPCS: CSRF ok, input var ok.
		$location_hash = self::geolocation_ajax_get_location_hash();
		$current_hash  = isset( $_GET['v'] ) ? wc_clean( wp_unslash( $_GET['v'] ) ) : ''; // WPCS: sanitization ok, input var ok, CSRF ok.
		if ( empty( $current_hash ) || $current_hash !== $location_hash ) {
			global $wp;

			$redirect_url = trailingslashit( home_url( $wp->request ) );

			if ( ! empty( $_SERVER['QUERY_STRING'] ) ) { // WPCS: Input var ok.
				$redirect_url = add_query_arg( wp_unslash( $_SERVER['QUERY_STRING'] ), '', $redirect_url ); // WPCS: sanitization ok, Input var ok.
			}

			if ( ! get_option( 'permalink_structure' ) ) {
				$redirect_url = add_query_arg( $wp->query_string, '', $redirect_url );
			}

			$redirect_url = add_query_arg( 'v', $location_hash, remove_query_arg( 'v', $redirect_url ) );

			wp_safe_redirect( esc_url_raw( $redirect_url ), 307 );
			exit;
		}
	}
}