Deprecated code notice

This page explains WP Geo Controller legacy features that remain temporarily available for backward compatibility. All deprecated behavior is controlled by the constant CFGP_ALLOW_DEPRECATED_METHODS. When this constant is disabled (recommended), legacy shortcodes and legacy PHP classes are turned off. When enabled, the plugin will allow legacy usage but will log deprecation warnings where applicable.

How to control deprecated behavior

Add the following line to your wp-config.php (before “That’s all, stop editing!”):

// Enable legacy shortcodes/classes (not recommended for production)
define('CFGP_ALLOW_DEPRECATED_METHODS', true);

// Disable legacy behavior and use the new API (recommended)
define('CFGP_ALLOW_DEPRECATED_METHODS', false);

Deprecated shortcodes

The following shortcodes are deprecated. Please replace them as shown below.

Old [cf_geo]New [cfgeo]
Old [cf_geo_flag]New [cfgeo_flag]
Old [cf_geo_map]New [cfgeo_map]

Behavior
If CFGP_ALLOW_DEPRECATED_METHODS is set to true, the old shortcodes will continue to work, but you should migrate to the new names as soon as possible. If the constant is false, only the new shortcodes will be processed.

Deprecated PHP class

The legacy class CF_Geoplugin is deprecated. Use the new utility and API classes instead: CFGP_U and CFGP_API.

Current classes
CFGP_U – utilities, helpers, accessors (preferred entry point).
CFGP_API – main API class responsible for lookup, caching and normalization of geo data.

Quick migration examples

Get the full API response (array) using the utility layer.

// 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.

// Helper accessor for a single value
$country = CFGP_U::api('country');      // e.g. "Germany"
$countryCode = CFGP_U::api('country_code');

Explicit lookup via the API class (advanced).

// Direct API call (advanced, e.g. custom IP or properties)
$response = CFGP_API::lookup('8.8.8.8', ['dns' => true]);
// Always validate keys defensively
if (is_array($response)) {
    $city = $response['city'] ?? '';
}

Notes
1) The new API normalizes values and caches responses to improve performance.
2) Always validate array keys (use null coalescing) to avoid notices in custom themes/plugins.
3) Prefer CFGP_U::api() for most cases; use CFGP_API directly only when you need low-level control.

Runtime and caching

The API layer uses internal cache to minimize external lookups and exposes standardized fields (country, country_code, region, city, timezone, currency, is_eu, is_mobile, and more). When migrating from CF_Geoplugin, check your field names and update them to the new normalized keys returned by CFGP_U::api().

Step 1: Set CFGP_ALLOW_DEPRECATED_METHODS to true temporarily, update templates and shortcodes, and verify that your site renders correctly.
Step 2: Replace all [cf_geo*] shortcodes with the [cfgeo*] versions across posts, pages and widgets.
Step 3: Replace any CF_Geoplugin references in theme or plugins with CFGP_U or CFGP_API as shown above.
Step 4: Switch CFGP_ALLOW_DEPRECATED_METHODS to false and test again.

Why deprecations?

The new architecture provides a unified, stable API surface with stricter typing, safer defaults and improved caching. It also removes inconsistencies between legacy shortcodes and PHP methods, making future maintenance easier.

Support
If you maintain a large codebase and need assistance with bulk migration or field mapping, contact support and include examples of legacy calls or shortcodes you still rely on.

Was this page helpful?