Linux 软件免费装

Honeill Visitor Country Detection

开发者 honeill
更新时间 2026年7月5日 14:50
PHP版本: 7.4 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

country geolocation geotargeting ip address visitor country

下载

1.2.4

详情介绍:

Honeill Visitor Country Detection detects a visitor's country (ISO 3166-1 alpha-2, e.g. GB) from their IP address using MaxMind's GeoLite2 database, and exposes it through a single WordPress filter so your theme or plugin can use it with no hard dependency. The GeoLite2 database is not bundled — MaxMind's license does not allow redistribution. Instead you enter your own free MaxMind license key once on the settings screen. The plugin then: You never download or upload a database by hand. Use it in your code $country = apply_filters( 'honeill_visitor_country_detection_country_code', '' ); Returns a two-letter country code, or an empty string when it can't be determined (local IP, missing database, etc.) — your code decides the fallback. Results are cached per IP, so it's cheap to call on every request. Prefer REST? GET /wp-json/honeill-visitor-country-detection/v1/country returns { "country": "GB" } for the caller. This product includes GeoLite2 Data created by MaxMind, available from https://www.maxmind.com. This plugin is an independent project and is not affiliated with, endorsed, or sponsored by MaxMind, Inc. GeoIP and GeoLite2 are trademarks of MaxMind, Inc.

安装:

  1. Upload the honeill-visitor-country-detection folder to /wp-content/plugins/, or install the ZIP via Plugins → Add New → Upload Plugin.
  2. Activate the plugin.
  3. Create a free MaxMind account and generate a license key (Account → Manage License Keys): https://www.maxmind.com/en/geolite2/signup
  4. Go to Settings → Honeill Visitor Country Detection, paste your license key, and click Save & download database.
  5. That's it — the database downloads now and auto-updates weekly.
Advanced: instead of the settings field you can define the key in wp-config.php with define( 'HONEILL_VISITOR_COUNTRY_DETECTION_LICENSE_KEY', 'your-key' ); to keep it out of the database.

常见问题:

Is it allowed to use GeoLite2 this way?

Yes. You use your own license key to download your own copy of the database — nothing is redistributed, which is what MaxMind's license restricts. Attribution to MaxMind is included as required.

Where is the database stored?

In wp-content/uploads/honeill-visitor-country-detection/. It is kept out of the plugin folder so plugin updates don't wipe it. The plugin also drops an .htaccess to block direct web access on Apache.

Can it detect city or region, not just country?

It ships with the lighter GeoLite2-Country database. City is a small change (the edition id and filename) but needs more disk space and exposes additional fields.

My site is behind Cloudflare / a load balancer. Will it still work?

Yes — it reads the left-most public IP from X-Forwarded-For, falling back to REMOTE_ADDR.

Downloads fail. Why?

Most often an incorrect license key (MaxMind returns 401/403), or the PHP Phar extension is disabled (needed to unpack the download). The settings screen shows both.

更新日志:

1.2.4 1.2.3 1.2.2 1.2.1 1.2.0 1.1.0 1.0.0