Geo Controller automatically provides global access to geolocation data that you can use in your theme or plugin.
Access global array
global $CFGEO; echo $CFGEO['city'];
Alternative: Load manually via class
The legacy CF_Geoplugin
class is deprecated. Please use the new CFGP_U
and CFGP_API
classes instead:
// Preferred usage $data = CFGP_U::api(); // Full structured geodata array $country = $data['country'] ?? ''; // Safe access to fields // Access a single field from the API via helper $country = CFGP_U::api('country'); // e.g. "Germany" $countryCode = CFGP_U::api('country_code'); // Explicit lookup via the API class (advanced) $response = CFGP_API::lookup('8.8.8.8', ['dns' => true]); // Always validate keys defensively if (is_array($response)) { $city = $response['city'] ?? ''; }
For details about deprecated code and migration instructions, see:
Deprecated Code Notice
Use these globals or the new API helpers anywhere in your WordPress project to access geolocation data like city, region, country, IP, and more.