=== Constile ===
Contributors: sponsoredaccess
Tags: ai agents, chatgpt, claude, sponsorship, paywall
Requires at least: 6.0
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.6.0
License: All rights reserved

Serves the Constile offer to AI agents that fetch your articles for a person. People, search engines, and crawlers get your pages as usual.

== Description ==

When an AI agent, such as ChatGPT or Claude, fetches one of your articles for a person, Constile shows it an offer: a sponsor pays for the person to read the article. People, search engines, and crawlers get your pages as usual.

The plugin:

* answers `/.well-known/constile`, so the network can confirm your install;
* answers the offer's callbacks under `/sponsored/`, and releases the article when a sponsor pays;
* registers the agent user agents as "don't cache" in WP Super Cache, W3 Total Cache, LiteSpeed Cache, and WP Rocket;
* serves your pages as usual whenever the network can't be reached.

== Installation ==

1. Download the plugin zip from your site page in the Constile dashboard.
2. Go to Plugins > Add New > Upload Plugin, choose the zip, and select Install Now. Then select Activate.
3. Go to Settings > Constile. Enter the site id, the site secret, and the network URL from your site page, and select Save Changes.
4. Select Check install. The plugin checks the settings and that your site answers, then the network checks the install itself: it sends a one-time code to your site, and the plugin confirms it with the site's credentials.

To keep the secret out of the database, define `CONSTILE_SITE_ID`, `CONSTILE_SITE_SECRET`, and `CONSTILE_NETWORK_URL` in `wp-config.php` instead.

== Frequently Asked Questions ==

= How do I turn it off quickly? =

On Settings > Constile, check "Turn the gate off" and save. It takes effect on the next request: every request goes to WordPress as if the plugin weren't installed. If you can't reach the settings page, add `define('CONSTILE_DISABLED', true);` to wp-config.php, or deactivate the plugin. Your pages, search crawlers, subscribers, and other ads aren't affected either way.

= My host has its own page cache. What do I do? =

Hosts such as WP Engine, Kinsta, SiteGround, and Cloudways cache pages before WordPress runs. Settings > Constile lists the agent tokens to exclude and what to ask each host.

= Does it work on multisite, or in a subdirectory? =

Not yet. On multisite, only a super admin can set the network URL and the connect URL. WordPress in a subdirectory doesn't serve /.well-known/constile at the domain's root, which the network checks; the install check says so.

= My cache plugin isn't one of the four you configure. =

When WP Fastest Cache, WP-Optimize, Cache Enabler, Breeze, or another page cache is active, the settings page and the install check name it. Exclude the agent tokens listed under Page caches in its own settings.

= A load balancer or CDN sits in front of WordPress. =

Enter its addresses or ranges under Trusted proxies. The plugin then reads the visitor's address from X-Forwarded-For when a request comes from one of them.

= The install check says the plugin can't fetch my pages. =

To get the page for an agent, the plugin requests it from your own site. If the server can't reach its public address, or a CDN blocks the server's requests, set the Connect URL, such as http://127.0.0.1. Until it works, agents get your pages as usual.

== Changelog ==

= 0.6.0 =
* Paywalled pages: the gate follows the network's release instructions.

= 0.5.0 =
* First release, with gate 0.5.0.
