=== Subset Opt-Out ===
Contributors: functionform
Tags: privacy, opt-out, gpc, cookies, ccpa
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Helps you honor US-style opt-out privacy choices: a "Do Not Sell or Share" link, Global Privacy Control, and blocking that works with page caching.

== Description ==

Subset Opt-Out helps you honor opt-out requests from your visitors. It is not legal advice, and using it does not by itself make a site compliant with any law. Talk to a lawyer about what your site needs.

* **Simple.** Scripts load as usual. The plugin acts only when a visitor opts out, or their browser sends Global Privacy Control (GPC).
* **Page-cache safe.** Every per-visitor decision happens in the browser, so the HTML is the same for every visitor.
* **Tiny.** One small front-end script and no database writes on the front end.
* **Stored by category.** Consent is stored as categories (functional, statistics, marketing). An opt-in mode is in Subset Opt-Out Pro.

What it adds to your site:

* **A "Do Not Sell or Share" link.** Add it as a block, the `[subset_cm_privacy_choices]` shortcode, a menu item or an automatic footer link. The page HTML is the same for every visitor. When a visitor's browser sends Global Privacy Control, the link also says "Opt-out request honored", because California's regulations ask you to show that the signal was processed. Without the link, nothing shows this.
* **A preferences panel.** The link opens a small dialog where the visitor allows or stops the sale and sharing of their personal information for targeted ads. It is built only when the link is used, so it adds nothing to the page until then.
* **Script blocking.** Tracking scripts from the built-in services, and any you add with a custom rule, are held until the visitor's choice allows them. A visitor who opts out, or whose browser sends GPC, never runs them.
* **An optional notice bar.** A slim bar at the bottom of the page for visitors who haven't made a choice and don't send GPC.

= For developers =

* The consent choice is stored in a first-party cookie, `subset_cm_consent`, for 12 months.
* Scripts can read and change the choice through `window.subsetCM` and listen for the `subset-cm:consent-changed` event.
* WP-CLI: `wp subset cookie-manager export`, `import`, `services`, `enable`, `disable` and `check <url>`. Run `wp help subset cookie-manager` for the options. `check` fetches the URL you give it and lists the scripts that would be held.
* WP-CLI settings: `wp subset cookie-manager settings list|get|set|reset` reads and changes any setting. A value the settings screen would refuse (link text that's too long, a colour that isn't hex, an invalid custom rule) is refused here too.
* WP-CLI custom blocking rules: `wp subset cookie-manager rules list`, `rules add <handle|url|inline> <value> [--category=statistics|marketing]` and `rules remove <id|value>...`. Rules are checked as the settings screen checks them, and nothing is saved if one is refused.
* Site Health (Tools > Site Health) warns when an active pixel plugin's tracking isn't held because the service that holds it is switched off. The Info tab has a Subset Opt-Out section: the consent model, how many services are switched on, custom rules, Global Privacy Control and Google Consent Mode.
* PHP filters: `subset_cm_services`, `subset_cm_blocking_rules`, `subset_cm_consent_categories`, `subset_cm_frontend_config`, `subset_cm_blocking_applies`, `subset_cm_blocking_buffer`, `subset_cm_settings_defaults`, `subset_cm_sanitize_settings`.
* JavaScript: `window.subsetCM` (`get`, `has`, `set`, `optOut`, `optIn`, `onChange`, `config`, `needsReload`) and the `subset-cm:reload-needed` event.
* Hold your own script by writing `<script type="text/plain" data-subset-cm-category="marketing" ...>`; it runs when the visitor allows that category.
* Parameters and examples for all of these are in the developer guide, `docs/developer.md`, in the plugin folder. `docs/integrations.md` covers tag managers and pixel plugins.

= Source code =

The front-end scripts in `assets/js/build/` (`main.js` and `head.js`) are minified. Their readable source ships with the plugin in `assets/js/src/`, and `bin/build-js.mjs` is the esbuild script that bundles them. To rebuild them, install Node.js 22 or later, then run `npm install --no-save esbuild@0.25` and `node bin/build-js.mjs` in the plugin folder. `node bin/build-js.mjs --watch` rebuilds on every change and doesn't minify. The Google Consent Mode script, `assets/js/inline/consent-mode.js`, isn't built: it's printed as it is.

== Installation ==

1. Upload the plugin to `/wp-content/plugins/`, or install it from the Plugins screen.
2. Activate it. On a multisite network you can activate it network-wide.
3. Open Subset > Opt-Out. Scan your home page, turn on the footer link and save. That is the whole setup.

== Frequently Asked Questions ==

= Does this make my site compliant? =

No. It helps you honor opt-out requests. Whether that is enough depends on your site and the laws that apply to it, so ask a lawyer.

= Does it work with page caching? =

Yes. The plugin prints the same HTML for every visitor, and the browser decides what to do with the visitor's choice.

= Does it work with caching and optimization plugins? =

Yes, with no setup. The plugin tells these plugins to leave its scripts alone: WP Rocket, LiteSpeed Cache, Autoptimize, Perfmatters and SiteGround Optimizer through their own exclusion settings, and Cloudflare Rocket Loader through `data-cfasync="false"` on the plugin's inline scripts. Blocked tracking scripts are inert markup (`type="text/plain"`) that these plugins skip, and the plugin makes sure the two that would otherwise combine them into a file that runs for everyone (WP Rocket's file combine and SiteGround's JavaScript combine) don't. The LiteSpeed Cache, Autoptimize and SiteGround Optimizer combinations are tested in a browser; WP Rocket, Perfmatters and Rocket Loader can't run in our automated tests, so those are checked by unit tests of the exclusions and attributes.

A few things stay yours to check:

* A tracking script that a theme or plugin prints before `wp_head`, or that an optimizer moves above the plugin's head script, runs before the plugin can decide about it. Move it below `wp_head()` or hold it with a custom rule.
* After changing an optimizer's JavaScript settings, clear its cache and test your own site as an opted-out visitor (or with Global Privacy Control on).

= Does it work with Google Analytics, Google Ads and Tag Manager? =

Yes. Google tags aren't blocked: they get Google Consent Mode v2 signals instead. Every visitor starts with ad and analytics storage granted, and a visitor who opts out (or whose browser sends Global Privacy Control) is switched to denied before any Google tag reads their consent. This works with gtag.js, Google Tag Manager and Site Kit by Google.

If you use Site Kit, leave its own Consent Mode setting off (it's off by default). Site Kit's Consent Mode targets opt-in regions such as the EU and UK, and this plugin already sends Google the visitor's choice, so turning both on means two consent policies are in play.

= What data does it store? =

A single first-party cookie, `subset_cm_consent`, in the visitor's browser, recording their choice for 12 months. Nothing about visitors is stored in your database.

= I uploaded the new version by hand and now see Subset Opt-Out twice =

Before 0.6.0 the plugin lived in a folder called `subset-cookie-manager`, so uploading 0.6.0 adds it next to the old copy instead of replacing it. Both copies use the same settings. Deactivate the old copy, then delete it: the Plugins screen marks which one is the old copy. If you update through the Subset Installer you won't see this, because the update replaces the old folder.

== Changelog ==

= 0.7.2 =
* Security: The Subset menu and its Overview page now need the same capability as a Subset page you can open, so a subscriber no longer reaches the Overview.
* Changed: Built on subset-core 1.13.3.

= 0.7.1 =
* Fixed: `wp help` for the `rules` command shows a whole sentence as its summary, and no longer lists internal helpers as subcommands.
* Changed: Built on subset-core 1.11.2.

= 0.7.0 =
* Changed: Add-ons now hook `subset_cm_admin_tab_{slug}`; the old `subset_cm_admin_panel_{slug}` hook still works but is deprecated. With `WP_DEBUG` on, using it logs a deprecation notice.
* Under the hood: shares more code with the other Subset plugins.
* Changed: Built on subset-core 1.11.1.

= 0.6.0 =
* Changed: The plugin now lives in a `subset-opt-out` folder, with the text domain `subset-opt-out`. If you update through the Subset Installer, nothing changes for you: the update moves it and keeps it active. Settings, visitors' choices, the Privacy Choices block and integrations keep working.
* New: If you upload this version by hand, it lands next to the old `subset-cookie-manager` copy. It waits until you deactivate the old copy, then takes over with the same settings, and the Plugins screen and Site Health tell you to delete the old copy.
* Changed: Built on subset-core 1.10.0.

= 0.5.4 =
* Fixed: `wp help` for the `settings` command is written for users, and its examples use this plugin's own command.
* Changed: Built on subset-core 1.9.1.

= 0.5.3 =
* Fixed: Cloudflare Rocket Loader no longer defers the plugin's script file. Its `data-cfasync="false"` attribute now comes before `src`, where Rocket Loader looks for it.

= 0.5.2 =
* New: When a visitor's browser sends Global Privacy Control, the privacy choices link says "Opt-out request honored", as California's CCPA regulations (§ 7025(c)(6)) have required since 2026. If the visitor then allows sale/sharing, it says the signal isn't applied.
* Fixed: The preferences panel no longer tells a visitor with Global Privacy Control on that they're opted out after they've chosen to allow sale/sharing.

= 0.5.1 =
* Fixed: WordPress no longer logs a "translation loading was triggered too early" notice for this plugin on admin pages.
* Changed: Built on subset-core 1.9.0.

= 0.5.0 =
* Changed: The settings screen won't save colours with too little contrast. Text colours need 4.5:1 against their background and the accent colour 3:1 against the notice background, and an imported settings file that breaks this is refused.
* Fixed: A menu link that opens the privacy notice now responds to the Space key as well as Enter.
* Fixed: Pressing Tab while focus is outside the open notice moves it to the notice's first control, and screen readers read an error on a custom cookie rule once instead of twice.
* Added: Add-ons can use the notice's interface helpers through `subsetCM.ui`.
* Changed: Built on subset-core 1.8.1.

= 0.4.4 =
* Fixed: A browser's Global Privacy Control signal now overrides a previously stored opt-in, as CCPA § 7025(c)(3) requires.

= 0.4.3 =
* Changed: The plugin is now called Subset Opt-Out. Settings and data are unchanged.

= 0.4.2 =
* Tweak: The About tab uses plain WordPress admin styling.

= 0.4.1 =
* Fix: accessibility and design polish for the privacy notice and settings screen. Keyboard and screen-reader behavior is smoother, colors you set are checked for readable contrast, and the notice holds up better on small screens, in right-to-left languages and in high-contrast mode.

= 0.4.0 =
* New: Cookie Manager now lives under the shared Subset menu (Subset > Cookie Manager). The old Settings address redirects.

= 0.3.0 =
* New: add-ons can add tabs to the settings screen through the subset_cm_admin_tabs, subset_cm_admin_panel_{slug} and subset_cm_admin_enqueue hooks.
* Fix: the JavaScript source now ships with the plugin, and output is escaped where it is printed.

= 0.2.0 =
* New: an About tab with a short introduction to Subset and a link to subsetwp.com.

= 0.1.0 =
* Opt-in groundwork: an add-on can switch the site to an opt-in regime (categories denied until a choice, Consent Mode denied, GPC and Reject deny everything optional) through the new subset_cm_selectable_regimes and subset_cm_regime filters.
* Settings screen (Subset > Cookie Manager): services with a home page scan, custom rules, the privacy choices link, notice bar and colors, privacy policy page, Google Consent Mode, and JSON export and import.
* First development release: plugin scaffold and consent model.
