=== itdatex AI Shield ===
Contributors: itdatex
Donate link: https://wp.itdatex.support/ai-shield/
Tags: ai, llm, crawler, llms.txt, indexnow
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.1.3
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Block AI crawlers on three levels or push your content to LLM search engines via llms.txt and IndexNow. Live counter in your dashboard.

== Description ==

**Two directions. One plugin. Your choice.**

AI Shield turns your WordPress into either a fortress against AI crawlers or a direct channel into the new LLM-powered search engines like Perplexity, SearchGPT and You.com.

= Blocker mode (default) =

Blocks over 40 AI crawlers (GPTBot, ChatGPT-User, ClaudeBot, Claude-Web, PerplexityBot, Google-Extended, Applebot-Extended, Bytespider, CCBot, Meta-ExternalAgent, Amazonbot, MistralAI-User, Cohere, Diffbot and many more) on three levels:

* **robots.txt** - a dedicated User-agent group per bot with `Disallow: /`, so every operator can agree or disagree individually.
* **Meta tags** - `noai, noimageai, SPC` plus bot-specific variants in the `<head>`. Respected by Stability, Midjourney, DeviantArt and several training pipelines.
* **HTTP headers** - `X-Robots-Tag: noai, noimageai` and `Content-Usage: ai=notrain, ai=noindex`. OpenAI, Google-Extended and Apple have each documented these signals as official opt-outs.
* **Hard block (403 interceptor)** - for bots like Bytespider, CCBot and Diffbot that ignore robots.txt. The request gets a 403 reply before WordPress even starts a query.

= Visibility mode =

Perplexity, SearchGPT and other LLM-powered search engines prefer to read `llms.txt`. AI Shield generates this file automatically:

* **llms.txt generator** following the llmstxt.org spec - Markdown from menu entries, pages, recent posts and a curated "About" block.
* **IndexNow push** to Bing, Yandex and Perplexity-compatible indexers on every publish/update. The site key is generated automatically and served at `/<key>.txt` - no manual FTP upload, no account.

= Live dashboard =

Two widgets, a lot of transparency:

* **Main page** with a hero counter "blocked today", 30-day trend as a Canvas chart (no external CDNs), top 5 bots, share buttons for X and LinkedIn.
* **WP dashboard widget** with the same counter right on admin login - the daily "wow" moment for the boss.

= Technical details =

* PHP 8.1+, WordPress 6.4+, no external Composer dependencies.
* Two custom tables (`wp_aishield_hits`, `wp_aishield_stats_daily`). Raw data is rolled into daily aggregates after 7 days.
* Admin chart in pure Canvas JavaScript - no Chart.js CDN, no external request, no GDPR issue.
* Logging stores truncated SHA-256 hashes of IP and User-Agent (16 bytes, with `wp_salt()`), never plaintext.
* Only outgoing traffic: IndexNow POST to the endpoints you configure - only your URLs, your site key.

== Installation ==

1. Upload the plugin via WP Admin > Plugins > Add New, or install from the plugin directory.
2. Activate.
3. Under *AI Shield > Dashboard* check that robots.txt and llms.txt are served correctly (direct links top right).
4. For Visibility mode: under *AI Shield > llms.txt* fill in the About text with your product/service description - exactly what will be quoted in Perplexity answers.

**Important:** If a static `robots.txt` or `llms.txt` lives in your web root, your web server delivers them directly and AI Shield never runs. AI Shield will show a warning in the admin area in that case.

== Frequently Asked Questions ==

= Should I block or stay visible? =

Both are legitimate. For a product shop or portfolio site you probably want to be visible (Visibility mode). For a specialist blog whose content would otherwise be quoted 1:1 in Perplexity answers without sending traffic, you want to block. Decide per site, not globally.

= Which bots actually respect the signals? =

OpenAI (GPTBot, ChatGPT-User, OAI-SearchBot), Google (Google-Extended, GoogleOther), Apple (Applebot-Extended), Anthropic (ClaudeBot, Claude-Web) and Meta (Meta-ExternalAgent) have officially documented the robots.txt opt-outs. Bytespider, CCBot, Diffbot and smaller scrapers often ignore them - only the hard 403 interceptor helps against those.

= Does IndexNow cost anything? =

No. IndexNow is an open standard from Microsoft and Yandex. api.indexnow.org and bing.com/indexnow provide the endpoints for free. No account needed.

= Is any data transmitted externally? =

No. All logging stays in your own WordPress database. The only outgoing traffic is the IndexNow ping - only your own permalinks plus your site key are sent to the endpoints you configure. No telemetry, no external analytics.

= What happens on deactivation and uninstall? =

Deactivation removes the cron jobs; settings and database stay untouched. On uninstall both tables (`wp_aishield_hits`, `wp_aishield_stats_daily`) and all options are deleted.

= My host does not allow sending HTTP headers from PHP. Does the plugin still work? =

Yes. Headers are one of three blocker levels. robots.txt and meta tags always work; you can disable the header toggle. The 403 interceptor works as long as PHP can call `exit` - so basically always.

= Can I allow some bots and block others? =

Yes. Under *AI Shield > Blocker > Bot list* every bot has its own toggle. Example: allow Perplexity (you want to appear in their answers) and block GPTBot.

= How often is IndexNow pinged? =

On every publish/update the URL is queued locally. An hourly cron sends up to 100 URLs per batch to each configured endpoint. The standard cron hook is `itdatex_aishield_indexnow_flush`.

== Screenshots ==

1. WP dashboard with the AI Shield widget: the daily "blocked today" counter right on admin login.
2. AI Shield main page: hero counter, 30-day trend chart, top bots, share buttons for X and LinkedIn.
3. Blocker settings with the full bot list (about 45 bots). Every bot individually toggleable.
4. llms.txt configuration with a live preview of the file served at /llms.txt.
5. IndexNow settings with key URL, endpoint list and queue status.

== Changelog ==

= 0.1.3 =
* Plugin renamed to "itdatex AI Shield" (slug `itdatex-ai-shield`) because the shorter name was already taken on wp.org. No functional changes.

= 0.1.2 =
* Interim rename attempt; superseded by 0.1.3.

= 0.1.1 =
* Fix: WordPress redirected /llms.txt via 301 to /llms.txt/ (canonical). The `redirect_canonical` filter now returns false when the llms query var is active.

= 0.1.0 =
* Initial release.
* Blocker: robots.txt filter (about 45 bots), noai/noimageai meta tags, X-Robots-Tag and Content-Usage HTTP headers, hard 403 interceptor.
* Visibility: llms.txt generator, IndexNow push (Bing + api.indexnow.org) on publish/update, automatic site key.
* Admin: dedicated menu with dashboard (hero counter plus 30-day Canvas chart), blocker settings with bot checklist, llms.txt preview, IndexNow queue.
* WP dashboard widget "blocked today".
* Custom tables for logging, daily aggregation.

== Upgrade Notice ==

= 0.1.3 =
Plugin renamed to "itdatex AI Shield" (slug `itdatex-ai-shield`). No functional changes.

= 0.1.1 =
Fixes the 301 redirect on /llms.txt. Recommended for all users in Visibility mode.
