Skip to content

guibranco/ipquery-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

🌍 IpQuery

Track and analyse every visitor. Visualise traffic. Detect threats.

A WordPress plugin that enriches visitor IP addresses with real-time geolocation, ISP data, and risk intelligence β€” powered by the IpQuery API via guibranco/ipquery-php.

Build Version WordPress PHP License

πŸ“– Documentation Β· πŸ› Report a Bug Β· ✨ Request a Feature


✨ Features

Feature Description
πŸ—ΊοΈ World heatmap Interactive Leaflet.js map with a heat layer weighted by visit count
πŸ“Š Country & city charts Horizontal bar chart of top countries; dedicated top-cities table with country flags
πŸ›‘οΈ Risk intelligence Per-IP flags for VPN, proxy, Tor, datacenter, and mobile connections
πŸ”’ Risk scoring Numeric risk score (0–100) per IP with colour-coded indicators
πŸ” Visitors table Searchable, sortable, filterable table with full enrichment data for every IP
πŸ”Ž Manual lookup Instantly enrich any IP address on demand from the admin panel
⚑ Non-blocking API calls run at shutdown β€” visitor page load is never delayed
πŸ—„οΈ Smart caching WordPress transients cache each IP for 1 hour; only one API call per IP per hour
🧹 Auto-retention Configurable data retention with daily WP-Cron cleanup
πŸ”’ Privacy controls Exclude IPs, skip logged-in users or admins, disable tracking at any time

πŸ–₯️ Admin screens

Dashboard

The plugin adds an IpQuery entry to the WordPress admin sidebar with three sub-pages.

Dashboard β€” a live overview built from four widgets:

  • Stat cards β€” total visits, unique IPs, VPN/proxy/Tor count, and overall risk rate
  • Visitor heatmap β€” world map with gradient heat layer (blue β†’ yellow β†’ red)
  • Top countries β€” bar chart (Chart.js) and a flag-annotated data table
  • Top cities β€” table with city name, country flag, visit count, and traffic share
  • Risk breakdown β€” doughnut chart and individual cards for each risk type

Visitors β€” full paginated table of every tracked IP with search, type filters, per-row delete, manual lookup form, and bulk purge.

Settings β€” all tracking options, data retention, excluded IPs list, and a system status panel.


πŸ—οΈ Architecture

Visitor browser request
        β”‚
        β–Ό  WordPress bootstrap
        β”‚
  [ init ]  IpQuery_Tracker registered
        β”‚
  [ wp ]    maybe_track()
        β”‚    β”œβ”€ skip: AJAX / REST / Cron
        β”‚    β”œβ”€ skip: logged-in / admin (configurable)
        β”‚    β”œβ”€ resolve IP (Cloudflare β†’ X-Real-IP β†’ X-Forwarded-For β†’ REMOTE_ADDR)
        β”‚    β”œβ”€ skip: private ranges, excluded IPs
        β”‚    β”œβ”€ transient hit  β†’  bump visit_count only
        β”‚    └─ transient miss β†’  register shutdown callback
        β”‚
  Page rendered & sent to browser ◄──── no latency added
        β”‚
  [ shutdown ]  lookup_and_store()
        β”‚
        β–Ό
  IpQueryClient::getIpData($ip)   ← guibranco/ipquery-php
        β”‚
        β–Ό
  GET https://api.ipquery.io/{ip}?format=json
        β”‚
        β–Ό
  IpQueryResponse { location, isp, risk }
        β”‚
        β–Ό
  IpQuery_DB::upsert()  β†’  wp_ipquery_visitors
        β”‚
        β–Ό
  set_transient( "ipq_{md5}", 1, HOUR_IN_SECONDS )

πŸ“‹ Requirements

Requirement Minimum
WordPress 6.0
PHP 8.2
PHP extension cURL
Database MySQL 5.7+ / MariaDB 10.3+

No Composer or external package manager needed β€” guibranco/ipquery-php is bundled inside includes/vendor/.


πŸš€ Installation

From GitHub releases

  1. Download the latest .zip from the Releases page.
  2. In your WordPress admin go to Plugins β†’ Add New Plugin β†’ Upload Plugin.
  3. Upload the .zip and click Install Now, then Activate.

Manually

git clone https://github.com/guibranco/ipquery-wordpress.git

Copy the ipquery-wordpress/ folder into wp-content/plugins/, then activate it from Plugins in the WordPress admin.

On activation

The plugin automatically:

  • Creates the wp_ipquery_visitors database table
  • Writes default settings to wp_options
  • Schedules a daily WP-Cron event for data retention cleanup

βš™οΈ Configuration

Navigate to IpQuery β†’ Settings to configure:

Setting Default Description
Enable Tracking βœ… On Master switch β€” disable to pause all tracking
Track Logged-in Users ❌ Off Whether authenticated visitors are tracked
Track Administrators ❌ Off Whether manage_options users are tracked
Look Up Private IPs ❌ Off Send private/LAN IPs to the API (useful for local dev)
Excluded IPs (empty) Newline-separated list of IPs to never track
Data Retention 90 days Records older than this are auto-deleted by cron

Full documentation: guilherme.stracini.com.br/ipquery-wordpress/configuration


πŸ—ƒοΈ Database schema

A single table wp_ipquery_visitors is created on activation:

id            BIGINT UNSIGNED  PRIMARY KEY AUTO_INCREMENT
ip            VARCHAR(45)      UNIQUE NOT NULL
country       VARCHAR(100)
country_code  VARCHAR(10)
city          VARCHAR(100)
state         VARCHAR(100)
zipcode       VARCHAR(20)
latitude      DECIMAL(10,7)
longitude     DECIMAL(10,7)
timezone      VARCHAR(100)
asn           VARCHAR(50)
org           VARCHAR(255)
isp           VARCHAR(255)
is_mobile     TINYINT(1)
is_vpn        TINYINT(1)
is_tor        TINYINT(1)
is_proxy      TINYINT(1)
is_datacenter TINYINT(1)
risk_score    SMALLINT(3)
first_seen    DATETIME
last_seen     DATETIME
visit_count   BIGINT UNSIGNED

πŸ“¦ Project structure

ipquery-wordpress/
β”œβ”€β”€ ipquery-wordpress.php          # Plugin bootstrap & constants
β”œβ”€β”€ includes/
β”‚   β”œβ”€β”€ vendor/                    # Bundled guibranco/ipquery-php
β”‚   β”‚   β”œβ”€β”€ IpQueryClient.php
β”‚   β”‚   β”œβ”€β”€ IpQueryException.php
β”‚   β”‚   β”œβ”€β”€ IIpQueryClient.php
β”‚   β”‚   └── Response/
β”‚   β”‚       β”œβ”€β”€ IpQueryResponse.php
β”‚   β”‚       β”œβ”€β”€ Isp.php
β”‚   β”‚       β”œβ”€β”€ Location.php
β”‚   β”‚       └── Risk.php
β”‚   β”œβ”€β”€ class-ipquery-db.php       # Table install, upsert, and query helpers
β”‚   β”œβ”€β”€ class-ipquery-tracker.php  # Visitor capture, IP resolution, caching
β”‚   └── class-ipquery-admin.php    # Admin menus, AJAX, action handlers
β”œβ”€β”€ admin/views/
β”‚   β”œβ”€β”€ dashboard.php              # Heatmap, charts, stat cards, tables
β”‚   β”œβ”€β”€ visitors.php               # Searchable/sortable visitor log
β”‚   └── settings.php               # Settings form & system status
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ css/admin.css
β”‚   β”œβ”€β”€ js/ipquery-maps.js         # Leaflet heatmap
β”‚   └── js/ipquery-charts.js       # Chart.js bar & doughnut charts
β”œβ”€β”€ docs/                          # Jekyll / Just the Docs site
β”‚   β”œβ”€β”€ _config.yml
β”‚   β”œβ”€β”€ index.md
β”‚   β”œβ”€β”€ installation.md
β”‚   β”œβ”€β”€ configuration.md
β”‚   β”œβ”€β”€ dashboard.md
β”‚   β”œβ”€β”€ visitors.md
β”‚   β”œβ”€β”€ tracking.md
β”‚   β”œβ”€β”€ api.md
β”‚   └── privacy.md
└── .github/workflows/
    └── docs.yml                   # GitHub Pages deployment

πŸ”Œ Powered by

Dependency Role
guibranco/ipquery-php PHP client library for the IpQuery API β€” bundled inside the plugin
IpQuery API Free IP intelligence service providing geolocation, ISP, and risk data
Leaflet.js Interactive world map rendering
Leaflet.heat Heatmap layer for Leaflet
Chart.js Bar and doughnut charts
OpenStreetMap Map tile provider
Flag CDN Country flag images

πŸ“– Documentation

Full documentation is available at guilherme.stracini.com.br/ipquery-wordpress.

Page Description
Installation System requirements and install steps
Configuration All settings explained
Dashboard Widget reference
Visitors Visitor table, filters, and lookup
How Tracking Works Technical flow and caching
IpQuery API API fields and PHP library reference
Privacy & GDPR Data collected, controls, and policy guidance

🀝 Contributing

Contributions, issues, and feature requests are welcome.

  1. Fork the repository
  2. Create a feature branch: git checkout -b feat/my-feature
  3. Commit your changes: git commit -m "feat: add my feature"
  4. Push to the branch: git push origin feat/my-feature
  5. Open a Pull Request

Please follow the WordPress Coding Standards for PHP files.


πŸ“„ License

Distributed under the MIT License. See LICENSE for full text.


Made with ❀️ by Guilherme Branco Stracini · Built on guibranco/ipquery-php

About

πŸŒπŸ“Š Track and analyse visitor IPs in WordPress using the IpQuery API. World heatmap, country & city breakdowns, and VPN/proxy/Tor risk detection.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors