=== AnonAge Age Verification ===
Contributors: cclambie
Tags: age verification, age gate, age restriction, compliance, online safety act
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.6.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Put an age gate over your site. Self-declaration that needs no account, no API key and no outbound requests, with three levels of enforcement.

== Description ==

AnonAge Age Verification puts an age gate in front of your content. It works out of the box with no account, no API key and no cost.

**Two free self-declaration modes**

* **Confirm** — the visitor clicks "I am over 18" (or 13, 16, 21).
* **Year of birth** — the visitor enters their year of birth. They are only asked for the month, and then the day, when the year alone does not settle it. Most people answer one question.

**Three levels of enforcement**

* **Cover the page** — the gate is drawn over the content in the browser. Cache-friendly and keeps the page fully indexable, but it is advisory: a visitor can remove it with developer tools, or by turning JavaScript off. Fine as a courtesy notice; it is not a lock.
* **Hide the restricted part** (recommended) — the page still loads and is still found by search engines. Everything below a marker you place never leaves your server until the visitor has proved their age. Works under any page cache with nothing to configure, because the page sent to every visitor is identical.
* **Withhold the whole page** — nothing but the gate is sent. The strongest option, and the right one for a page with nothing safe to show, but search engines see only the gate.

**Built for real WordPress sites**

* **Works with your cache plugin.** The gate is applied in the browser, so the HTML served to every visitor is identical. Nothing to configure in WP Rocket, LiteSpeed, W3TC or Cloudflare.
* **No flash of gated content.** The cover is painted from `<head>` before the page renders, not after everything has already appeared on screen.
* **Administrators are never gated** by default, so you can still edit your site.
* Gate the whole site, selected pages (ticking a parent covers its children), or everything under a URL path such as `/gated/`. Set how long a visitor stays through the gate, exclude URLs and roles, and restyle every part of the panel.
* **Membership sites**: for a logged-in visitor the result is recorded against their account, so they verify once rather than once per device. Fires `anonage_member_verified` for your own records.
* No third-party requests. No tracking. Nothing is loaded from anyone else's server.

**Verified mode — not in this release**

Self-declaration is honest about what it is: anyone can click a button. Verified mode checks the visitor's age against a real identity check through the AnonAge app — they scan a QR code, or tap through on a phone, and your site receives a yes or no. You never see their documents, their name or their date of birth. That is the mode that meets "highly effective age assurance" style requirements.

**It is not enabled in this version.** The code is here and the option is visible in the settings, marked as arriving in a later release, so that nothing about your gate changes when it does. It is switched off rather than left selectable because a mode that appears to check identity and does not is worse than one that is plainly unavailable. Everything described above this line works today and always will, with no account.

When it arrives it will need an AnonAge account and a paid plan. There is no free live tier: an account costs a one-time £2 set-up fee for the identity check on your own account, and then from £2 a month, which includes 10,000 verifications. Up to 50,000 a month is £5, and beyond that £2.50 per additional 50,000 — so 200,000 a month is £12.50 and a million is £52.50. USD and EUR are charged at the same numbers rather than converted. Test keys are free and are never counted against any of it. Billing follows usage, with no manual plan changes, and you can set a monthly cap and warning thresholds so a spike is not a surprise invoice.

* Your secret key never leaves your server. The QR code carries only an opaque session reference.
* Results arrive over an HMAC-signed callback that is verified against the raw request body, with a timestamp window so an old result cannot be replayed.
* If your site cannot receive inbound requests — a firewall, a staging domain, localhost — the plugin asks AnonAge for the result instead, so verification still completes.
* The QR code is generated on your own server. Nothing is sent to a third-party image service.

== Is this "highly effective age assurance"? ==

It depends on two independent choices, and both have to be right.

**How the age is checked.** Self-declaration is a statement by the visitor, not a check — anyone can click a button or type a year. It is what most sites run and it is a reasonable default, but it is not highly effective age assurance. Verified mode, which checks against a real identity check, is.

**How the content is protected.** "Cover the page" delivers the content and hides it in the browser, so it can be recovered with developer tools. "Hide the restricted part" and "Withhold the whole page" do not deliver it at all.

Getting one right and not the other achieves nothing: a real identity check behind a removable overlay still lets a child read the page. The settings screen warns you if you configure that combination.

== External services ==

The free self-declaration modes make **no external requests at all**. Nothing leaves your server.

Verified mode communicates with the AnonAge API at `https://api.anonage.io` to open a verification session and receive its result. Your secret API key stays on your server and is never sent to the browser. The data exchanged is a session identifier, a one-time nonce and a yes/no answer — no personal data about your visitor is sent to us or returned to you.

* Terms: https://anonage.io/terms
* Privacy policy: https://anonage.io/privacy

== Installation ==

1. Upload the plugin to `/wp-content/plugins/` or install it from the Plugins screen.
2. Activate it.
3. Go to **Settings → AnonAge**, choose a mode and a minimum age, and save.

== Frequently Asked Questions ==

= Do I need an AnonAge account? =

No. Everything in this release — both self-declaration modes, all three enforcement levels, all of the appearance and targeting options — is free, needs no account and makes no outbound requests of any kind. Nothing about your gate depends on us being reachable.

An account and a paid plan are only needed for verified mode, which is not enabled in this release.

= What will verified mode cost? =

There is no free live tier, and we would rather say so plainly than have you find out at the point of switching it on. A one-time £2 set-up fee covers the identity check on your own account, then from £2 a month including 10,000 verifications; £5 a month up to 50,000; and £2.50 per additional 50,000 after that, so 200,000 a month is £12.50 and a million is £52.50. The same numbers are charged in USD and EUR rather than being converted. Test keys are free and never counted, so you can build and test the whole integration before paying anything.

The visitor pays a small fee for their own identity check as well. Between the two, that is what funds the service — rather than us making money from data about your visitors.

= Will this break my page cache? =

With "Cover the page" or "Hide the restricted part", no, and there is nothing to configure. The page sent to every visitor is identical — the gate is applied in the browser, and in split mode the restricted content is fetched separately over a request that is never cached. Do not add the `anonage_verified` cookie to any "vary cache on this cookie" list; it would fragment your cache for no benefit.

"Withhold the whole page" is the exception. That decision has to be made per visitor, so PHP has to run — and on a cache hit it does not. The plugin therefore marks every gated page as uncacheable, which WP Rocket, W3 Total Cache, WP Super Cache and LiteSpeed all honour automatically. If you have a CDN in front of your site, including Cloudflare, add your own rule to bypass the cache on those URLs.

= Will it hide my site from Google? =

That depends on which enforcement level you choose, and it is the main thing to think about.

"Cover the page" changes nothing — the content is delivered in full and indexed as normal.

"Hide the restricted part" is the balance most sites want: the page, its title, its description and everything you place above the marker stay indexable, while the restricted part is withheld. Put your descriptive, keyword-carrying copy above the gate and it does the SEO work for the page.

"Withhold the whole page" does hide those URLs from search engines, because the crawler receives the gate and nothing else. Use it only on pages with nothing safe to show, and keep your landing and category pages ungated so the site stays findable.

There is no way to withhold content from visitors and still have that content indexed. Serving search engines something visitors do not get is cloaking, and it is penalised. This plugin does not do it.

= Can someone bypass it? =

With "Cover the page", yes — developer tools will remove any overlay, on any site, from any plugin, and turning JavaScript off stops the overlay existing at all. That level is advisory by design and is labelled as such.

With "Hide the restricted part" or "Withhold the whole page", no: the content is not in the page at all, so there is nothing in the browser to reveal. The server checks a signed cookie in PHP before releasing it.

If you are relying on this for a legal obligation, pair verified mode with one of those two — a real age check behind an overlay anyone can dismiss enforces nothing.

= What does it store about my visitors? =

One cookie, `anonage_verified`, holding the age threshold they cleared and when it expires. It is signed with your site's own key so it cannot be forged. No personal data, no analytics, no tracking.

== Screenshots ==

1. The Gate tab: how the age is checked, how much of the page is withheld, and what the gate applies to.
2. The gate as a visitor sees it, over a page they have not passed.
3. The same page once they have.
4. The proof that "Hide the restricted part" is not just an overlay — with the gate's own element deleted in developer tools, the restricted content is still not there.
5. Verified mode (coming soon, not yet available): a QR code the visitor scans with the AnonAge app. Nothing but a session reference is in the code.
6. Placing the split with the `[anonage_gate]` block. Everything above it stays public and indexable.
7. Appearance: colours, logo, background image and corner radius.
8. Content: every string in the panel is yours to rewrite.
9. Connection (for verified mode, coming soon): the API key, and a live check that the callback can reach your site.
10. Advanced: excluded roles and URLs, how long a visitor stays through the gate, and debug logging.

== Changelog ==

= 0.6.1 =
* All CSS and JavaScript now goes through the WordPress asset APIs. The gate's cover has to be inline — it carries the site owner's own colours and has to be in place before the page paints — but it is now attached to registered handles with wp_add_inline_style() and wp_add_inline_script() instead of being printed as tags, and the block-mode page's stylesheet moved into the enqueued file. No <style> or <script> tag is written by the plugin any more.
* The page-tree indentation on the settings screen is a class rather than an inline style, so the whole admin screen's CSS lives in the enqueued stylesheet.

= 0.6.0 =
* Verified mode is explicitly unavailable in this release rather than selectable. It was gated on a check that could never fail, so it could be switched on against an API that is not yet in production — a mode that looks like it checks identity and does not is worse than one that is plainly marked as coming later.
* Documented what verified mode will cost when it arrives, including that there is no free live tier, so nobody discovers the price at the point of switching it on.
* Corrected the description: it advertised verified age checks as though they were available today.

= 0.5.0 =
* Tested against WordPress 7.0.
* Housekeeping for the plugin directory review: no behavioural changes.

= 0.4.0 =
* Server-side enforcement. "Hide the restricted part" withholds everything below a marker until a signed cookie is verified in PHP, while keeping the page indexable and cache-safe; "Withhold the whole page" sends nothing but the gate and marks the page uncacheable.
* Target the gate at a URL path, and ticking a parent page now covers its children. The page picker shows the hierarchy and marks what is covered by inheritance.
* Membership sites: a logged-in visitor's verification is stored against their account, so it carries across devices. New `anonage_member_verified` action.

= 0.3.0 =
* Appearance: gate background image with cover, contain, tile and centre fits, over a fallback colour that shows while the image loads.
* Content: separate wording for the verify button and the QR instruction.

= 0.2.0 =
* Verified mode: sessions opened server-side, an on-server QR generator, mobile deeplink, HMAC-signed result callback, status polling and a poll fallback for sites that cannot receive inbound requests.
* Per-visitor cap on session creation so a script cannot burn a site's verification allowance.

= 0.1.0 =
* First release: self-declaration modes (confirm, and year of birth), settings screen, appearance and content customisation, page/URL/role targeting, cache-safe client-side gating.
