=== HiRizzi AI SEO ===
Version: 1.4.1
Author: HiRizzi
License: Commercial

== Description ==
Optimizes WordPress sites for AI search engines — ChatGPT, Perplexity, Gemini, and Google AI Overviews — instead of just traditional Google search.

Most SEO plugins only target the old "10 blue links" model. This plugin targets the new one: getting your content read, understood, and cited by AI answer engines — plus the housekeeping basics (redirects, 404s, sitemap) every site still needs.

Features:
1. llms.txt Generator — serves an AI-readable summary of your site at /llms.txt (the emerging llms.txt standard)
2. AI Crawler Access Control — explicitly allow or block GPTBot, ClaudeBot, PerplexityBot, Google-Extended, and other AI crawlers via robots.txt, instead of leaving it to chance
3. FAQ Schema Builder (Bulk + per-page) — Q&A builder that outputs FAQPage JSON-LD, the single highest-leverage format for AI citation. The Bulk FAQ Generator lets you select multiple pages, generate with Claude, review every answer, then save all at once.
4. Bulk SEO Generator — AI-written meta titles/descriptions for many pages at once, with the same select → review → save workflow. Disables itself automatically if Yoast, RankMath, All in One SEO, SEOPress, or HiRizzi SEO is already active, since those plugins already own the title/meta fields — the AI-citation features above are unaffected either way.
5. Citation Readiness Score — a per-post structural score (headings, list usage, paragraph length) showing how "liftable" your content is for AI answer engines
6. AI Bot Activity Tracking — logs visits from known AI crawlers so you can see which bots are actually reaching your content and which pages they hit most
7. Redirect Manager — 301/302 redirects from an old/broken path to a working URL, no .htaccess editing required
8. 404 Monitor — logs real 404 hits (bot/scanner noise filtered out) so you can see which broken links matter and turn any of them into a redirect in one click
9. XML Sitemap — a plain sitemap at /sitemap.xml covering your homepage, pages, and posts

== Important Honesty Note ==
No plugin (including this one) can show you confirmed citations inside ChatGPT, Perplexity, or Google AI Overviews — that data isn't publicly exposed by any AI provider. The Bot Activity feature tracks crawler visits as a useful proxy signal, and the UI is worded to reflect that distinction clearly rather than overclaiming "citation tracking."

== Licensing ==
This is a commercial plugin. FAQ Schema and the Citation Readiness Score work without a license so you can evaluate real value before buying. llms.txt generation, AI Crawler Access Control, Redirect Manager, 404 Monitor, and the XML Sitemap require an active license key, validated against LemonSqueezy.

Setup for the developer/seller:
1. ✅ Done: the product exists in LemonSqueezy (Store #410767, Product #1165792)
2. ✅ Done: HAISEO_LS_STORE_ID and HAISEO_LS_PRODUCT_ID are hardcoded at the top of hirizzi-ai-seo.php
3. Set up the checkout button on hirizzi.com/premium-plugins/ pointing to that product

== Installation ==
1. Upload the `hirizzi-ai-seo` folder to /wp-content/plugins/
2. Activate from WP Admin > Plugins
3. Go to AI SEO > License to activate your key
4. Go to AI SEO > llms.txt to write your site summary and key pages
5. Go to AI SEO > Crawler Access to review/adjust which AI bots can crawl your site
6. Edit any post/page to add FAQ schema and see its Citation Readiness Score

== Changelog ==

= 1.6.1 =
* Refresh Analysis now scans current Gutenberg content, including unsaved edits.
* Added focus keyword checks for H1-H3 headings, introduction, and URL slug.
* Added sentence and paragraph readability checks.
* Improved keyword density matching with Unicode-aware phrase boundaries.
* Distinguished missing image alt attributes from intentional empty decorative alt values.
* Added Product and Article/BlogPosting schema types.
* Expanded Recipe, Software Application, and Local Business schema fields.
* Added server-side validation for prices, currencies, ratings, coordinates, dates, and ISO 8601 durations.
* Hardened per-post AI generation authorization.



= 1.6.0 =
* Added Keyword Density and Image Alt Tag checks to the Basic SEO Analysis tab — flags when your focus keyword appears too rarely/frequently in body content, and lists images missing alt text.
* Added an Advanced Schema builder supporting Recipe, Software Application, and Local Business schema types (in addition to the existing FAQ schema) — manual entry only, since this is factual data that shouldn't be AI-generated.

= 1.5.3 =
* Fixed the "opening paragraph" detection regex incorrectly matching `<path>` SVG elements (e.g. Google login icons) as if they were `<p>` paragraph tags, which could cause the Citation Readiness Score's short-intro check to analyze unrelated SVG/markup content instead of the real first paragraph.
* Added a browser-like User-Agent to the internal page fetch used for pages with custom templates, for compatibility with servers running bot-protection on non-browser requests.
* Added a missing `twitter:image` tag — Open Graph image was previously only set for Facebook/LinkedIn-style previews, not Twitter/X card previews.

= 1.5.1 =
* Fixed an ID collision between the Basic SEO Analysis checklist and Citation Readiness checklist that could replace the Citation Readiness items and hide the “Suggest a fix” buttons in the block editor sidebar.

= 1.5.0 =
* Added "Suggest a fix" buttons to the Citation Readiness Score panel for the question-heading, short-intro, and missing-list checks. Uses your configured Anthropic API key to generate a suggestion you can review and copy in yourself — nothing is ever written to your content automatically.

= 1.4.2 =
* Fixed a bug in the Citation Readiness Score's "question-phrased heading" check where any heading containing inline formatting tags (e.g. `<em>`, `<strong>`) would fail to be detected even if it correctly ended in a question mark. The check now correctly strips inner tags before testing for a question mark.

= 1.4.1 =
* Added the "❓ How does this page work?" help popup to the Bulk FAQ Generator — missed in 1.4.0's rollout across the other pages. Covers what FAQ schema is, that it works without a license (unlike llms.txt/Crawler Access/Redirects/404 Monitor), and how the exclude list connects to llms.txt's settings.

= 1.4.0 =
* Added "❓ How does this page work?" help popups to Bulk SEO Generator, Redirects, 404 Monitor, AI Crawler Access, Settings, and AI Bot Activity (in addition to llms.txt from 1.3.3) — covering the exact points of confusion that came up most during real use: why Bulk SEO disables itself when another SEO plugin is active, the Redirects/404 Monitor connection, Google-Extended vs. regular Googlebot, the "Save before Test Connection" behavior, and what Bot Activity does and doesn't prove about AI citation.

= 1.3.4 =
* The Key Pages "Generate Descriptions for Selected" status message now shows a full breakdown instead of just a total — e.g. "Done: added 46, 2 already in list, 6 skipped (no usable content — try again) out of 54 selected." Previously a mismatch between selected count and added count (from already-in-list dedup or the AI skipping a page) was invisible.

= 1.3.3 =
* Added a "❓ How does this page work?" popup to the llms.txt Generator, explaining Site Summary, Key Pages, Auto-Pulled Content, and the Exclude list — including an explicit warning against running a large Key Pages list together with Auto-Pulled Content at the same time, since that duplicates the same URLs in the generated file.

= 1.3.2 =
* Fixed "AI response could not be parsed" when generating descriptions for a large number of selected pages at once. The output token limit was fixed at 1000 regardless of selection size, so anything beyond roughly 15-20 pages got cut off mid-JSON and failed to parse; it now scales with how many pages are selected. The input text sent to Claude was also capped at 6,000 characters, silently truncating the page list itself for larger selections — raised to 40,000.

= 1.3.1 =
* The Key Pages picker and the actual saved list looked like the same information shown twice. Now clearly split into "① Add Pages" (the picker — a shaded box) and "② Your Key Pages List" (the actual output that gets saved — marked with a green accent border), with an explicit note that step ① only adds, it never removes.

= 1.3.0 =
* Key Pages (under llms.txt) now has a checkbox list of your posts/pages — same "Select all / Select none" pattern as the Bulk SEO and Bulk FAQ Generators — instead of relying on the AI to blindly scan everything and guess which 4-8 pages matter. Check the pages you actually want featured, click "Generate Descriptions for Selected," and Claude writes a one-sentence description for each one you picked. New entries are appended without duplicating pages already in the list. The old "let AI pick automatically" behavior still runs as a fallback if you generate without selecting anything.

= 1.2.4 =
* Fixed the "Choose Image" button on the Social (Open Graph) Image field not opening — it was checking whether the WordPress media library had finished loading at the moment the page rendered, rather than at the moment you actually click the button, so the click handler was silently never attached if the media scripts hadn't loaded yet. It now checks at click time. Since the standard WordPress media picker always includes an "Upload Files" tab alongside "Media Library," this also gives you a direct upload option — no separate button needed for that.

= 1.2.3 =
* Added a "Choose Image" button next to the Social (Open Graph) Image field on the post/page edit screen, using the WordPress Media Library — no more needing to manually find and paste an image URL. Pasting a URL directly still works too.

= 1.2.2 =
* Added an unsaved-changes warning to the Bulk FAQ Generator and Bulk SEO Generator: once you generate drafts, a visible banner reminds you nothing is saved yet, and your browser will warn you before you can accidentally navigate away or close the tab and lose the generated work.

= 1.2.1 =
* Fixed a bug where, on sites also running another HiRizzi plugin that shares the HAI_Settings/HAI_API or DT_AI_Client integration (e.g. AI Toolkit Pro), a stale or invalid key configured in that OTHER plugin would silently block this plugin's own dedicated Anthropic API key from ever being used — "Test Connection" and all AI features would fail with an authentication error even though this plugin's own key was valid and correctly saved.
* HAISEO_AI_Bridge::call() now falls through to this plugin's own configured key if the shared integration returns an error, instead of treating "a shared integration exists" as an unconditional, unrecoverable first choice.

= 1.2.0 =
* Added Redirect Manager: 301/302 redirects from any old path to a working URL, managed from AI SEO > Redirects.
* Added 404 Monitor: logs real 404 hits (automated bot/scanner probing filtered out), with a one-click "turn this into a redirect" action from AI SEO > 404 Monitor.
* Added XML Sitemap at /sitemap.xml covering the homepage, pages, and posts — independent of whatever other SEO plugin's sitemap may already be running, with a settings toggle to turn it off if you'd rather not publish two.
* All three new features are gated behind an active license, consistent with AI Crawler Access Control and Bot Activity Tracking.
* Existing installs pick up sane defaults for the new settings automatically on the next page load — no need to deactivate/reactivate after updating.

= 1.1.1 =
* Security hardening release. Changes:
* Removed the HAISEO_LICENSE_OVERRIDE developer bypass constant entirely — Pro features can no longer be enabled by any PHP constant, only by a validated license key.
* Secured the premium updater: the real update package URL is now withheld unless the site has an active license (checked at two independent points — when the update manifest is built, and again at actual download time via upgrader_pre_download), preventing unlicensed sites from pulling paid update packages.
* Hardened API key handling: the saved Anthropic API key is never re-printed into the settings page. The field starts blank, a masked preview (e.g. sk-***...abcd) is shown separately, and submitting the form with the field left blank preserves the existing key instead of erasing it.
* Added uninstall.php: deleting the plugin now removes its settings, cached transients (including timeout rows), the AI bot log database table, and scheduled cron events — including per-site cleanup across multisite installs.
* Cleared the bot-log cleanup cron event on plugin deactivation, so no orphaned scheduled job remains after deactivating.
* Hardened all 9 outbound HTTP requests (license validation, AI generation, update checks, on-page content fetches) with explicit redirection limits and response-size caps, reducing exposure to malformed or oversized responses.
* Replaced a manual string-concatenation innerHTML assignment (OG image live preview) with safe DOM element creation, removing the one spot in the codebase that wasn't using the existing safe-escaping pattern already used everywhere else.
* Fixed the FAQ Schema meta box's registration priority so it consistently renders below the Basic SEO box on every edit screen, instead of occasionally appearing above it depending on load order.

= 1.0.7 =
* Fixed a real licensing gap on this already-published, already-sold plugin: HAISEO_LS_PRODUCT_ID was still an empty placeholder, which meant the product-match check in class-haiseo-license.php was silently skipping itself - any valid LemonSqueezy license key from any of HiRizzi's other products (e.g. AI Toolkit Pro) would have validated as an active license for this plugin too, and vice versa.
* Hardcoded the real Store ID (#410767) and Product ID (#1165792) directly into hirizzi-ai-seo.php. A license key now only activates Pro features if it genuinely belongs to this specific product.
* Existing customers should update to this version - their own real license keys are unaffected and will continue to work exactly as before.

= 1.0.0 =
* Initial release: llms.txt generator, AI crawler access control, FAQ schema builder, citation readiness score, AI bot activity tracking, LemonSqueezy license gating
