Geocode Switch
GeoSwitch is a plugin that allows you to change the content of your site based on the location of your client’s IP. To geolocate users based on IP GeoSwitch supports can user either the new the new GeoIP2 MaxMind databases or GeoIP2 Precision Service. MaxMind offers free and paid geolocation databas
GeoSwitch is a plugin that allows you to change the content of your site based on the location of your client’s IP. To geolocate users based on IP GeoSwitch supports can user either the new the new GeoIP2 MaxMind databases or GeoIP2 Precision Service. MaxMind offers free and paid geolocation databases and the paid GeoIP2 Precision web service, the author of this plugin is not affiliated with MaxMind in any way.
The main development of this plugin is in github . Please open a new issue if you find a bug in this plugin.
This plugin uses the MaxMind PHP library which is released under the Apache License version 2.0
Usage
= GeoSwitch Conditional Blocks =
GeoSwitch uses two shortcodes [geoswitch] and [geoswitch_case] to create conditional blocks. The [geoswitch] shortcode is used to enclose one or more [geoswitch_case] shortcodes with different conditions. The [geoswitch_case] shortcodes enclose content that will be shown if the condition is true. The following example illustrates a GeoSwitch conditional block that will show different contact information depending on the user’s IP location:
[geoswitch] [geoswitch_case country_code="AU" state_code="NSW"]New South Wales Office[/geoswitch_case] [geoswitch_case country_code="AU"]Australian Office[/geoswitch_case] [geoswitch_case]International Office[/geoswitch_case] [/geoswitch]
The above GeoSwitch block will display “New South Wales Office” to users in New South Wales within Australia, “Australian Office” to other Australian users and “International Office” to any other user.
The [geoswitch_case] shortcode accepts the following attributes:
- country – comma delimited list of country names
- country_code – comma delimited list of country ISO codes
- state – comma delimited list of of state names
- state_code – comma delimited list of state ISO codes
- city – comma delimited list of city names
- within , from – This set of attributes is used to test for distances. Within is the distance in kilometers or miles and from is the centre point represented as “latitude,longitude” in degrees (example [geoswitch within=”10” from=”-33.7167,151.6”]).
The [geoswitch_case] shortcode matches only the attributes specified so: