Skip to content

How to migrate from v1 to v2

benjaminpick edited this page Dec 4, 2014 · 19 revisions

New Function Names

In order to preserve backwards compatibility, the new API got new functions:

function geoip_detect2_get_info_from_ip($ip, $locales = array('en')) { ... } function geoip_detect2_get_info_from_current_ip($locales = array('en')) { ... }

As you can see, you can now indicate a language that you want your labels in. Not all names are translated in all languages, so you can give an fallback order (array('de', 'en') means "German if possible, English otherwise"). List of supported locales

Legacy Code

The old function names return the same data structure as before, only filled with the v2-data.

Properties that might not work:

  • region and region_name: As the data-basis changed, there seem to be less regional coding (or maybe that's because it's the light version
  • timezone: Similarly, there is less data available. If it is not available, the plugin tries to fill it in - but without a region to rely on this only works in so many countries (ie countries with only 1 timezone).
Clone this wiki locally