Developer Reference
GeoBlock Pro exposes constants, filters, actions, and a PHP API that developers can use to extend or modify its behaviour.
Constants
| Constant | Value | Description |
|---|---|---|
GEOBLOCK_PRO_VERSION | 1.0.0 | Pro plugin version |
GEOBLOCK_PLUGIN_FILE | __FILE__ | Absolute path to main plugin file |
GEOBLOCK_PLUGIN_DIR | plugin_dir_path() | Absolute directory path |
GEOBLOCK_PLUGIN_URL | plugin_dir_url() | Public URL of plugin directory |
Pro-Added Filters
| Filter | Arguments | Description |
|---|---|---|
geoblock_pro_bulk_rules | $rules (array) | Modify bulk rules before evaluation |
geoblock_pro_payment_rules | $rules (array) | Modify payment gateway rules before evaluation |
geoblock_pro_analytics_event | $event (array) | Modify or cancel an analytics event before it is logged; return false to skip logging |
geoblock_pro_variation_rule | $rule (array|null), $variation_id (int), $country (string) | Override variation rule for a specific variation + country combination |
geoblock_pro_rule_priority | $priority (int), $rule_type (string) | Adjust rule evaluation priority |
Pro-Added Actions
| Action | Arguments | Description |
|---|---|---|
geoblock_pro_restriction_logged | $event (array) | Fires after an analytics event is written to the database |
geoblock_pro_bulk_rule_saved | $rule (array) | Fires when a bulk rule is created or updated |
geoblock_pro_payment_rule_saved | $rule (array) | Fires when a payment rule is created or updated |
Options Schema
| Option Key | Type | Pro Default | Description |
|---|---|---|---|
geoblock_settings | array | (inherited + pro keys) | All plugin settings |
geoblock_settings[analytics_enabled] | string yes/no | yes | Enable analytics event logging |
geoblock_settings[bulk_rules] | array | [] | Array of bulk rule objects |
geoblock_settings[payment_rules] | array | [] | Array of payment gateway rule objects |
wcgb_license_key | string | '' | Encrypted license key |
wcgb_license_status | string | inactive | License status |
Post Meta Keys
| Meta Key | Scope | Format | Description |
|---|---|---|---|
_geoblock_rules | Product | JSON object | Per-product restriction rule (inherited from free) |
_geoblock_variation_rules | Variable Product | JSON object keyed by variation ID | Per-variation restriction rules |
PHP API
// Check if a specific variation is restricted for a country
$is_restricted = GeoBlock_Pro_Restrictions::is_restricted_for_country(
$product, // WC_Product object
'US' // ISO 3166-1 alpha-2 country code
);
// Get full restriction context (mode, message, redirect URL, matched rule)
$context = GeoBlock_Pro_Restrictions::get_restriction_context( $product );
// Returns: [ 'restricted' => bool, 'mode' => string, 'message' => string,
// 'redirect_url' => string, 'rule_type' => string, 'rule_id' => int ]
// Log a custom analytics event
GeoBlock_Pro_Analytics::log_event([
'event_type' => 'restriction',
'action' => 'hide',
'rule_type' => 'custom',
'country' => 'DE',
'product_id' => 42,
]);
// Query analytics data
$data = GeoBlock_Pro_Analytics::get_dashboard_data( 30 ); // last 30 days
$summary = GeoBlock_Pro_Analytics::get_summary();
$top_countries = GeoBlock_Pro_Analytics::get_top_countries( 10 ); // top 10When reading analytics data in custom code, be aware that results are cached with a 5-minute TTL via the WordPress object cache. Call wp_cache_delete() if you need immediate freshness.