Your location:

get_real_IP_address(); $error = false; $my_country = ''; $my_country_isoCode = ''; $my_city = ''; try { $reader = $api->get_GeoIP2_city_reader(); // $reader = $api->get_GeoIP2_country_reader(); if( $reader ){ // Look up the IP address // $record = $reader->country($ip); $record = $reader->city($ip); if ( ! empty( $record ) ) { $my_city = $record->city->name; $my_country = $record->country->names['en']; $my_country_isoCode = $record->country->isoCode; $my_region = isset( $record->subdivisions[0]->name ) ? $record->subdivisions[0]->name : '(unknown region)'; $my_lat = $record->location->latitude; $my_long = $record->location->longitude; $my_continent_code = $record->continent->code; } } else { $error = __( 'Geo Database not found', AAGT_SLUG ); } } catch (\GeoIp2\Exception\AddressNotFoundException $e) { $error = $e->getMessage() . ' ' . __( "Maybe you are working on a local or secured environment." ); } if( $error ){ $current_location = '' . $error . ''; } else { if( ! $my_city ){ $my_city = __( '(unknown city)' ); } $current_location = $ip . ', ' . $my_country . ', ' . $my_city; } echo "your IP: $ip
your continent: $my_continent_code
your country: $my_country
your region: $my_region
your city: $my_city
lat/long: $my_lat / $my_long"; else : _e( "Geo Targeting add-on is missing." ); endif; ?>