Documentation
GeoBlock Pro
Developer Reference

Developer Reference

GeoBlock Pro exposes constants, filters, actions, and a PHP API that developers can use to extend or modify its behaviour.


Constants

ConstantValueDescription
GEOBLOCK_PRO_VERSION1.0.0Pro plugin version
GEOBLOCK_PLUGIN_FILE__FILE__Absolute path to main plugin file
GEOBLOCK_PLUGIN_DIRplugin_dir_path()Absolute directory path
GEOBLOCK_PLUGIN_URLplugin_dir_url()Public URL of plugin directory

Pro-Added Filters

FilterArgumentsDescription
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

ActionArgumentsDescription
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 KeyTypePro DefaultDescription
geoblock_settingsarray(inherited + pro keys)All plugin settings
geoblock_settings[analytics_enabled]string yes/noyesEnable 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_keystring''Encrypted license key
wcgb_license_statusstringinactiveLicense status

Post Meta Keys

Meta KeyScopeFormatDescription
_geoblock_rulesProductJSON objectPer-product restriction rule (inherited from free)
_geoblock_variation_rulesVariable ProductJSON object keyed by variation IDPer-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 10

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