=== WPLocation - Geolocation and Country Rules ===
Contributors: wplocation
Tags: geolocation, geotargeting, country, visibility
Requires at least: 6.8
Requires PHP: 7.4
Tested up to: 7.1
Stable tag: 1.1.10
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Show posts, pages, categories and selected content by visitor country with a local GeoLite2 Country database.

== Description ==

WPLocation is a country visibility plugin for WordPress. Set an audience for posts, pages or categories, use the country visibility block or [wplocation_target] shortcode, and display a detected country with [wplocation_country]. The admin menu includes Settings, Diagnostics and a private activity log. Pro and optional add-ons are distributed separately; no paid feature code is bundled or locked inside this plugin. Free is distributed and updated through WordPress.org. Pro 1.4.5 or newer extends the same Free foundation and requires PHP 8.3.

Local country lookup needs a current, licensed GeoLite2 Country MMDB. Separately installed, trusted country-source adapters may provide a verified country through the extension hook; their infrastructure and privacy requirements are documented by that adapter. No visitor-country service or paid account is required by Free itself. It does not bundle location data. You can select a private server file or use your own MaxMind account ID and license key to download one from Settings. Automatic updates are opt in and off by default. When enabled, the updater contacts MaxMind for an authorized download and follows its signed Cloudflare R2 file URL. The providers receive your site's server IP and MaxMind receives the account credentials. Visitor IPs remain on your server during local lookups and are not sent by the updater. See https://dev.maxmind.com/geoip/geolite2-free-geolocation-data/, https://www.maxmind.com/en/geolite/eula, https://www.maxmind.com/en/privacy-policy and https://www.cloudflare.com/privacypolicy/.

Saved MaxMind credentials are non-autoloaded WordPress options, not encrypted at rest; they may appear in database backups. For stronger secret management, define WPLOCATION_MAXMIND_ACCOUNT_ID and WPLOCATION_MAXMIND_LICENSE_KEY in wp-config.php. Those constants take priority. The plugin does not display saved keys or record them in its activity log.

Store the MMDB outside the public web root. Automatic updates save validated copies beside the configured source, select them atomically and retain the last working file on failure. Recorded unchanged retired copies can be removed after two days; configured and untracked files remain the site's responsibility. WordPress cron needs traffic or a server cron. Follow MaxMind's database update and deletion requirements. This product can use GeoLite Data created by MaxMind, available from https://www.maxmind.com/.

Geolocation is approximate and these rules are for personalization, not access control for confidential content. When a country cannot be determined, restricted content is hidden. Caches and CDNs can serve the wrong country or bypass WordPress altogether. While Free is active, the plugin requests no-store responses for frontend HTML and country-aware post, page and search REST reads because targeted content can appear in posts, blocks and secondary queries. It purges WP Super Cache when its API is present, but you must configure and test any shared cache. Forwarded IP headers are not trusted by default; verified infrastructure can provide an address with the wplocation_verified_client_ip filter.

Upgrading an older standalone build requires a current country source. A database stored inside the old plugin folder is removed by WordPress's replacement flow; this release does not bundle, restore or silently copy obsolete location data. Before updating, back up the site and rules, prepare a current licensed GeoLite2 Country MMDB outside the plugin folder and public web root, and select it with the documented upgrade preparation tool or configuration constant. Existing private database settings and audience storage keys are retained. Without a readable source, country-restricted output stays hidden and the dashboard provides recovery steps. Purge and test every external page or CDN cache after updating.

For older content, standard post and text-widget rendering translates [locationtarget] markup to [wplocation_target] before WordPress processes shortcodes. This does not register the unprefixed legacy shortcode and does not edit saved posts or revisions. Escaped examples are preserved; another plugin that registers the old tag keeps ownership. Use the prefixed shortcode for new content. Page-builder metadata, custom fields and direct do_shortcode() integrations need a separate review and conversion. Private database settings and content are per site on multisite; prepare and verify every site before a network update.

The combined plugin is GPLv3 or later and contains third-party libraries under their own licenses, including Apache-2.0 MaxMind libraries. See THIRD-PARTY-NOTICES.txt and vendor license files.

== Installation ==

1. If upgrading an older standalone build, back up the site and prepare a current licensed database outside the plugin folder before replacing it. Review custom shortcode integrations as described above.
2. Install and activate WPLocation.
3. In WPLocation > Settings, select an existing private GeoLite2 Country MMDB or save your own MaxMind credentials and download one. Alternatively define WPLOCATION_GEOIP_DB_PATH in wp-config.php; this constant takes priority. Illustrated setup: https://wplocation.com/documentation/maxmind-geolite2-country-setup/.
4. In Diagnostics, verify the database date and run a private IP lookup. Create a country rule and test the page with your actual cache and CDN configuration.
5. If you enable automatic updates, monitor WordPress cron and the update status. Purge external page and CDN caches after plugin, data or rule changes.

== Frequently Asked Questions ==

= Does it work without a MaxMind account? =

Yes, if you already have a current, licensed GeoLite2 Country MMDB that you can maintain. The in-plugin GeoLite download requires your own MaxMind account and license key.

= Does it secure confidential content? =

No. IP location is approximate. Other APIs, feeds, queries and caches may expose content. Use WordPress access controls for confidential material.

= Is every page cache or CDN compatible? =

No. A cache can serve an existing response before this plugin runs. Test targeted URLs from different countries and bypass or vary shared cache entries when necessary. WP Super Cache is purged on activation, updates and rule or data changes when its API is available. Other caches need their own purge or configuration.

== Screenshots ==

1. Select the countries that can see a WordPress page and review the resulting audience.
2. Check whether the private country database is ready and when it was built.
3. Overview: country-source health, saved audiences and setup checklist.
4. Search countries in the Country visibility block editor.
5. Compare Free, Pro and separately installed add-ons.

== Changelog ==

= 1.1.10 =
* Unify Free improvements in the WordPress.org plugin; retire the separate website distribution.
* Redesign Overview with saved audience counts, source health, setup steps and geolocation, cache and SEO guidance.
* Improve the audience editor, add-on controls and Free/Pro comparison without stale embedded pricing.
* Normalize older ISO/name choices in the country picker and explain how to repair malformed saved audiences.
* Replace the old post-editor table with a compact, searchable Country audience panel and explicit Everyone control; invalid saves retain the prior rule.
* Add searchable country choices and an audience summary to the visibility block editor; retain saved block content.
* Translate legacy shortcode markup during standard content rendering without registering an unprefixed shortcode or rewriting saved content.
* Preserve private database and rule settings, and explain recovery when an older bundled database is no longer available.
* Add a validated optional country-source hook and source status for separately installed adapters.
* Restrict changes to network-active add-ons to network administrators; reject malformed audience tokens safely.
* Purge supported page caches on deactivation as well as rule, data and version changes.
* Preserve scoped REST cache headers, PHP 7.4 compatibility and the trimmed vendor package.

= 1.0.0 =
* Preserve safe form fields in conditional content while filtering unsafe HTML.
* Provide a compatibility marker for Pro 1.4.4 or newer without changing the migration-safe directory version number.

* Initial WordPress.org release under the wplocation slug. Version 1.0.0 shared the legacy version number to avoid offering an unattended update to old standalone installations.
* Validate admin inputs as they enter the plugin and document why read-only navigation needs no nonce and why the update lock uses direct SQL.
* Correct the MaxMind credential-removal checkbox layout and publish key-free GeoLite setup and data-source guides on wplocation.com.
* Add post, page and category audience rules, country visibility block, country shortcodes, Diagnostics, Activity Log and mobile admin screens.
* Support a private GeoLite2 Country MMDB and opt-in MaxMind downloads with validated file replacement, rollback and cleanup.
* Clarify migration, data licensing, privacy and cache limitations. The DB-IP source is excluded from this directory edition while its attribution requirements are reviewed.

== Upgrade Notice ==

= 1.1.10 =
Back up first. Legacy standalone builds need a current licensed country database outside the plugin folder before updating. Private settings and rules are retained. Standard legacy shortcode markup is translated; custom integrations need review. Purge caches and test.
