Automattic\WooCommerce\Internal\StockNotifications\Frontend

SignupRateLimiter::get_ip_address │ private static │ WC 1.0

Get the IP address to rate limit a guest request on.

Only REMOTE_ADDR is trusted by default: forwarded headers are attacker-controlled unless the store is actually behind a proxy that sets them. With proxy support on, the address comes from the forwarding headers the rest of WooCommerce trusts.

Метод класса: SignupRateLimiter{}

Хуков нет.

Возвращает

string. The IP address, or an empty string if it could not be resolved.

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

$result = SignupRateLimiter::get_ip_address( $proxy_support ): string;
$proxy_support(true|false) (обязательный)
Whether to read the client address from forwarding headers.

Код SignupRateLimiter::get_ip_address() WC 11.2.2

private static function get_ip_address( bool $proxy_support ): string {
	if ( $proxy_support ) {
		return WC_Geolocation::get_ip_address();
	}

	$ip_address = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ?? '' ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated -- format-validated below via rest_is_ip_address().

	return (string) rest_is_ip_address( $ip_address );
}