This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

IP Loc8

Lýsing

This plugin would figure out a user location (country and city, but have in mind that the city information is only 60% reliable) by matching his IP address to an IP addresses database. The information would then be stored in a cookie and in a global variable, to be used by other plugins or themes. This happens quietly in the background without the user seeing anything.

Furthermore, for sites using qTranslate X for multilanguage, it can set the language of the site upon the user’s first visit, using country-based rules that you set up in the plugin options. Normally qTranslate X offers automatic setting of language based on the browser language, but in many countries browser localisation is not as popular and a lot of people use english language browsers, so this method is not reliable and some people would prefer to set the language based on the user’s country.

This plugin does not do much on its own (except for the integration with qTranslate) – it provides valuable data to be integrated with other code on your website. The idea behind it is to have a fast, simple and reliable tool for getting location, which could be used on a per-need basis. The plugin loads no scripts and no stylesheets and uses class autoloading to load its code only when it’s actually needed.

It also does its best to recognize robots, crawlers and content fetchers and only run for regular site visitors.

Future verions will also provide a tool for precise geolocation, using the user’s GPS and WiFi data (html5 geolocation).

Features

  • Automatically gets country and city by IP address and saves it in a cookie and a global variable
  • Possible qTranslate X language setting based on country, upon first visit
  • Ability to get precise geolocation information by asking for user permissions and using his GPS and WiFi data

Uppsetning

This plugin needs cURL PHP extension! PHP sessions should also work properly on your server, to avoid querying the IPDB on every page load by users with cookies disabled.

  1. Upload the plugin folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the ‘Plugins’ menu in WordPress.

SOS

The plugin does not work!

If the plugin does not seem to locate the country the problem might be a connection timeout. The curl connection timeout is conservatively set to 2 seconds for CURLOPT_CONNECTTIMEOUT and 4 seconds for CURLOPT_TIMEOUT, so that the page loading time is not severely delayed when the servers are not responding. Still, in most cases this should be enough. If you experience timeouts often write on GitHub or the WordPress support forums and the limits will be reconsidered.

How long does the cookie remain in the browser?

The cookie is kept for 2 weeks only. People with smartphones and tablets often move, so we do not want to have data that is very old.

What if cookies are disabled?

The information is also stored in a global variable $visitorGeolocation. The plugin also uses the user session to store the information, so that the IP database is queried only upon the first page load.

What if I want to do other things upon first page load?

If you want to do some additional things upon first page load (set currency in your shop, for example), there are two ways to do that:
1. Use the ‘iploc8_set_country’ action, which is only run upon first page load (country 2 letter code is passed as a variable).
2. Check if the ‘IPLOC8NEW’ constant is defined. It is defined only at the first page load and its value is the user’s country 2-letter code.

Umsagnir

Skoða 1 umsögn

Þátttakendur & höfundar

“IP Loc8&#8221 er opinn hugbúnaður. Eftirfarandi aðilar hafa lagt sitt af mörkum við smíði þessarar viðbótar.

Höfundar

Translate “IP Loc8” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Breytingarsaga

1.1

  • Updated code

1.0

  • First release