Merge pull request #22608 from woocommerce/performance/remove-external-ip-lookup

Performance: Remove external lookup of ips on localhost
This commit is contained in:
Mike Jolley 2019-02-08 13:09:31 +00:00 committed by GitHub
commit 0d901a2eca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -148,7 +148,7 @@ class WC_Geolocation {
/**
* Get user IP Address using an external service.
* This is used mainly as a fallback for users on localhost where
* This can be used as a fallback for users on localhost where
* get_ip_address() will be a local IP and non-geolocatable.
*
* @return string
@ -191,7 +191,7 @@ class WC_Geolocation {
* @param bool $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower).
* @return array
*/
public static function geolocate_ip( $ip_address = '', $fallback = true, $api_fallback = true ) {
public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) {
// Filter to allow custom geolocation of the IP address.
$country_code = apply_filters( 'woocommerce_geolocate_ip', false, $ip_address, $fallback, $api_fallback );

View File

@ -1102,7 +1102,7 @@ function wc_get_customer_default_location() {
$ua = strtolower( wc_get_user_agent() );
if ( ! strstr( $ua, 'bot' ) && ! strstr( $ua, 'spider' ) && ! strstr( $ua, 'crawl' ) ) {
$location = WC_Geolocation::geolocate_ip( '', true, false );
$location = WC_Geolocation::geolocate_ip( '', false, false );
}
// Base fallback.