=== GeoBlocker Pro System ===
Contributors: mcstaydesigns
Tags: geoblock, country block, security, cloudflare, ip block
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Professional country blocking engine with Cloudflare headers, IP whitelisting, live AJAX connection logs, and administrative lockout protection.

== Description ==

GeoBlocker Pro System provides high-performance, lightweight geographic security control for WordPress sites. Restrict unwanted traffic from targeted countries, protect administrative login pages, and inspect blocked traffic in real time.

Built specifically for high-traffic environments, GeoBlocker Pro leverages zero-overhead Cloudflare headers when available and falls back to cached geolocation API lookups to prevent server slowdowns.

= Key Features =

* **Cloudflare Accelerated Detection:** Instantly inspects `HTTP_CF_IPCOUNTRY` headers for 0ms lookup latency on Cloudflare-routed traffic.
* **Smart API Geolocation Fallback:** Automatically resolves unknown IPs via background API queries with 14-day transient caching to minimize external calls.
* **Real-Time Connection Log Feed:** Auto-polling dashboard interface updates blocked access attempts every 5 seconds without requiring page reloads.
* **IP Whitelist Lockout Protection:** Explicitly bypass rules for administrator static IPs or team networks to prevent accidental locked-out states.
* **Flexible Action Modes:** Display a custom 403 Forbidden HTML error page (with `{country}` and `{ip}` dynamic tags) or execute an immediate external URL redirect.
* **One-Click CSV Export:** Export full blocked log history (timestamps, IP addresses, country codes, and User-Agents) for offline security audits.
* **Admin Security Protection:** Built-in capability checks ensure logged-in site administrators (`manage_options`) maintain uninterrupted access to `/wp-admin` and `wp-login.php`.
* **Privacy Compliant:** Fully transparent opt-in telemetry system (disabled by default) compliant with WordPress.org guidelines.

== Installation ==

1. Upload the `geoblocker-pro` directory to the `/wp-content/plugins/` directory, or upload the ZIP file directly via **Plugins > Add New > Upload Plugin**.
2. Activate the plugin through the **Plugins** menu in WordPress.
3. Navigate to **GeoBlocker Pro** in the administrative sidebar menu.
4. Select the countries you wish to restrict and enter your current IP address into the **IP Whitelist** box.
5. Choose your restriction action (Custom HTML Message or Redirect URL) and click **Save Protection Settings**.

== Frequently Asked Questions ==

= Will this plugin lock me out of my site? =
No. GeoBlocker Pro includes built-in safeguards:
1. Logged-in administrators with `manage_options` permissions bypass block rules on `wp-admin` and `wp-login.php`.
2. You can add your IP address to the IP Whitelist box to guarantee permanent access.

= How does Cloudflare integration work? =
If your website is proxied through Cloudflare, the plugin automatically detects the `HTTP_CF_IPCOUNTRY` and `HTTP_CF_CONNECTING_IP` headers. This bypasses external API lookups completely, saving processing time and database overhead.

= What happens if I am not using Cloudflare? =
The plugin queries a secure IP geolocation API service and caches the country code in WordPress transients for 14 days per unique IP address.

= Where are blocked connection logs stored? =
Logs are recorded in a lightweight custom database table (`wp_geoblock_logs`) created upon plugin activation. You can view, search, export to CSV, or truncate logs directly from the dashboard.

== Screenshots ==

1. `screenshot-1.png` - GeoBlocker Pro main administrative settings dashboard and country selector.
2. `screenshot-2.png` - Live blocked connection logs table with auto-polling controls and CSV export.
3. `screenshot-3.png` - Custom block action settings and HTML message editor.

== Changelog ==

= 1.3.0 =
* Added AJAX nonce verification to live log polling endpoint.
* Added live connection polling toggle (Pause/Resume).
* Improved Cloudflare proxy IP extraction logic (`HTTP_X_FORWARDED_FOR` handling).
* Implemented full CSV export functionality.

= 1.2.0 =
* Added IP Whitelist support.
* Implemented transient caching for external IP geolocation lookups.

= 1.0.0 =
* Initial public release.

== Upgrade Notice ==

= 1.3.0 =
Version 1.3.0 includes critical security enhancements for AJAX log polling and updated Cloudflare header detection. Recommended update for all users.