Plugin Directory

Test out the new Plugin Directory and let us know what you think.
!This plugin hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Ochre W3C Geolocation Services

Geolocation Services attempts to retrieve a visitor's physical location, allowing for geographically relevant content to be delivered.


Global Configuration is available from the WordPress settings->Ochre Geolocation page:

  • Global or per-post/per page geolocation behavour

Per-page and per-post configurations include:

  • Executing custom javascript
  • Redirecting to a URL
  • Performing a page refresh
  • Firing off the ochregeo actions but doing nothing on the front end
  • Disabling completely


The following actions for do_action() are fired when a Geolocation update is received:

  • ochregeo_received_nosupport : No Geolocation support in the device/browser
  • ochregeo_received_unknownpos : A position could not be retrieved
  • ochregeo_received_location : Position was received. This action is passed the OCHRELABS_WP_Geolocation object as its only argument

AJAX actions

The following AJAX actions are implemented:

  • (nopriv) ochregeo_ochregeos : Transmits location information and executes an action based on a per-post/page or global setting.
  • (nopriv) ochregeo_get_coordinates : Retrieves last received location information. (we haven't tested this)

Executing custom javascript after a succesful Geolocation update

Javascript executed on a per-page/post or global basis has access to a res object containing information from the Geolocation Service plugin.

Properties of this object are:

res.la; // latitude
res.ll; // longitude
res.ev; // elevation (not always available - do not rely on)
res.ac  // accuracy (not always available - do not rely on)

If reverse geo coding is enabled, the object may also contain:

res.country  // country
res.countryc // country code
res.state    // state
res.statec   // state code
res.city     // city

El Quickie API Reference

// This is the Ochre Geo object instantiated by the plugin.
$ochre_geo = new OCHRELABS_WP_Geolocation();    

// Get status of the current geolocation request.  $ochre_geo::STATUS_UPDATED means you have "valid" coordinate data.
// Constants are:
  $ochre_geo::STATUS_QUERY;        // waiting for update from client
  $ochre_geo::STATUS_UPDATED;      // received coordinate update from client
  $ochre_geo::STATUS_NOTSUPPORTED; // client does not support geo location
  $ochre_geo::STATUS_ERROR;        // an error was returned from the client
  $ochre_geo::STATUS_UNKNOWNPOS;   // location was unknown
  $ochre_geo::STATUS_DISABLED;     // module has been told not to present geolocation query


// Set the location information manually (not normally needed)

// get the current resolved location information - check get_status() first before relying on this data!
// the returned array will be something like: array("latitude"=>49.1234, "longitude"=>"-123.1234","elevation"=>0,"accuracy"=>0);

// geocodes the current resolved location information and returns it as an array like array("city"=>"Vancouver","country"=>"Canada","state"=>"British Columbia","statec"=>"BC","country"=>"Canada","countryc"=>"CA")

Reverse Geo Coder

We've thrown in Yahoo! place finder Geocoding support. The geocoder() returns an array consisting of something like:

    "state"=>"British Columbia",

Geo Coding support is still young and subject to change. It's not hooked into the Javascript API, and since there are at least a few geo coder javascript api's already out there we haven't decided whether to do this or not.

Requires: 3.0.0 or higher
Compatible up to: 3.3.2
Last Updated: 5 years ago
Active Installs: 10+


0 out of 5 stars


Got something to say? Need help?


Not enough data

0 people say it works.
0 people say it's broken.

0,1,0 100,1,1