=== Essiow — AI SEO Suite for WooCommerce ===
Contributors: boni58
Tags: woocommerce, seo, ai, product-descriptions, chatbot
Requires at least: 5.8
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.1.58
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Get more Google traffic on WooCommerce. AI rewrites your products, categories and articles using your real Google Search Console data — and pings every search engine to index changes instantly.

== Description ==

**Essiow turns your WooCommerce store into a search-traffic machine.** It plugs into Google Search Console, watches what your customers actually search for, and rewrites your product pages, category pages and blog articles to capture every query you nearly rank on.

You don't write SEO. You don't pick keywords. You don't guess what works. You click a button and the right pages get fixed.

= What Essiow does for you =

**1. Auto-rewrites your product pages.** Long description, short pitch, meta title, meta description, focus keyword, image alt texts — all generated from your real GSC queries when connected, in 8 languages, in your store's tone. Compatible with Yoast SEO, Rank Math and All in One SEO.

**2. Turns empty category pages into landing pages.** Bare category pages don't rank. Essiow generates 1,500-2,500 words of category content with FAQ, comparison tables and links to your top products — the page Google needs to rank you in position 1 instead of position 30.

**3. Writes blog articles that pull traffic to your products.** 1,500-5,000 word articles with internal links to the products mentioned, FAQ schema, automatic featured image. Suggestions based on what your audience already searches.

**4. Spots and grabs every "almost-ranking" keyword.** When Google Search Console is connected, Essiow surfaces every query where your store sits at position 11-20 — the closest gains. One click rewrites the matching page targeting that exact query.

**5. Resolves cannibalization in two clicks.** Two of your pages competing for the same query? Essiow detects it, picks the strongest one, and consolidates the canonical from the others — without deleting anything.

**6. Indexes everything instantly.** Bing, Yandex, Naver, Seznam are pinged the second you publish. Google gets the URL pushed via sitemap re-submit + URL Inspection refresh + a one-click manual indexation request.

**7. Builds your internal mesh in a graph view.** See orphan pages (no incoming links), dead-ends (no outgoing), and connect any two pages with a drag — Essiow injects reciprocal anchor links on the strongest shared keyword. A live mesh score / 100 tells you how healthy your site structure is.

**8. AI sales agent on your storefront.** A chatbot that knows your full catalog, handles objections, can issue promo codes within your discount limit, and quotes your delivery / returns / payment policy.

**9. Exposes your catalog to ChatGPT, Perplexity and Claude.** Toggle on and Essiow serves a clean `/llms.txt` at your root — the standard AI search engines read to find products to recommend.

= Why it ranks better =

When Search Console is connected, every optimization sees the actual queries the page is already ranking on, the striking-distance keywords just outside page 1, and the CTR alerts when a title is converting poorly. The AI doesn't guess keywords — it gets them from Google itself, and writes around what's already working.

= Made for shop owners, not SEOs =

* No keyword research needed
* No technical setup beyond pasting an API key
* Every action shows its credit cost upfront — no surprise billing
* Bulk optimize, pause, resume, restore original — your content is always recoverable
* 8 languages, 4 writing tones, 3 content lengths

= Compatible & safe =

* WooCommerce HPOS compatible
* Works alongside Yoast SEO / Rank Math / All in One SEO (writes to all three)
* GDPR compliant (auto-delete chat data after 90 days)
* Original content backed up the first time you optimize — one-click restore

= How credits work =

* **1 credit** per product optimization
* **1 credit** per category optimization
* **3 credits** per blog article
* **2 credits** per AI Vision alt text generation
* All indexation actions, audits, internal-link suggestions, mesh-score, /llms.txt — **free** (no AI involved)
* Credits are debited only on success. Failed AI calls don't consume credits.
* Purchased credits never expire (free trial credits expire after 30 days)

= External Service =

This plugin connects to the Essiow API at `https://essiow.com/api/v1` to process AI content generation. Your product data (names, descriptions, prices, categories) is sent to the Essiow servers where it is processed using OpenAI's models. No data is stored beyond what is needed to track your credit usage.

* [Essiow Terms of Service](https://essiow.com/terms)
* [Essiow Privacy Policy](https://essiow.com/privacy)

== Installation ==

1. Upload the `essiow` folder to `/wp-content/plugins/`
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Go to **Essiow > Settings** and enter your API key from [essiow.com](https://essiow.com)
4. Click "Test Connection" to verify
5. Start optimizing from **Essiow > Products** or **Essiow > Categories**

== Frequently Asked Questions ==

= Do I need an Essiow account? =
Yes. Create a free account at [essiow.com](https://essiow.com) to get your API key and 10 free credits.

= Do I need technical skills? =
No. If you can install a WordPress plugin, you can use Essiow. Everything is done in a few clicks.

= Do I need to know SEO? =
No. Essiow does the SEO work : it picks the keywords (from Google Search Console when connected), writes the meta tags, generates the schema, builds the internal links and submits everything to search engines. You just click "Optimize".

= Why does connecting Google Search Console matter? =
With GSC connected, every optimization is fed with the real queries your page already ranks on. Essiow finds queries where you sit at position 11-20 (just outside page 1) and rewrites the matching page targeting that exact query. Without GSC, optimizations are still good — but generic. With GSC, they're surgical.

= Will optimizing break my existing content? =
No. The first time a product or category is optimized, the original content is backed up automatically. One click in the preview modal restores it.

= Which SEO plugins are supported? =
Essiow works with Yoast SEO, Rank Math, and All in One SEO. It writes to all three formats simultaneously, so switching SEO plugin later does not lose your data.

= Is my data safe? =
Your product data is sent to Essiow servers only during optimization. It is processed in real-time and not stored beyond credit-tracking metadata. Chat conversations are auto-deleted after 90 days per GDPR requirements.

= Do credits expire? =
Purchased credits never expire. The 10 free credits expire after 30 days.

= Can I cancel a bulk optimization? =
Yes. Pause / Resume / Cancel buttons appear during a bulk run. Closing the tab also auto-cancels — items already processed remain saved.

= Can I try before buying? =
Yes. Create a free account and get 10 credits to test all features. No credit card required.

== Screenshots ==

1. Dashboard with connection status and credit balance
2. Product optimization with SEO score and bulk actions
3. Category optimization with rich content preview
4. Blog article generator with async processing
5. AI Sales Agent configuration
6. Settings page with API connection

== Changelog ==

= 1.1.58 =
* **Fix critical**: Automesh stuck on "0 / undefined pages processed" on shared / low-spec hosts (EazyWP, Hostinger, low-tier OVH, etc).
* Two combined root causes :
  1. **Truncated AJAX response** from `ajax_automesh_start` : on a 1000+ page site, computing the plan takes 30-60s. PHP's default `max_execution_time` (30s) on shared hosting truncates the JSON response mid-write. The plugin received a partial response with `success:true` but `total` undefined → `0 / undefined` displayed.
  2. **WP-Cron broken / disabled** : many shared hosts disable `DISABLE_WP_CRON` without setting up a real cron, or block loopback HTTP (used by `spawn_cron()`). The worker `cron_automesh_run` was scheduled but never executed → 0 pages processed indefinitely.
* Fix 1 (server-side hardening) : `ajax_automesh_start` now wraps the plan computation in `try/catch`, sets `set_time_limit(300)`, raises memory via `wp_raise_memory_limit('admin')`, and returns a clean error with detail if it crashes — instead of a truncated 200 response.
* Fix 2 (worker stall detection + sync fallback) : `ajax_automesh_status` now detects when a task has been pending/running for 20s+ without any tick. When stalled, it (a) re-schedules the WP-Cron event and (b) **executes ONE batch synchronously** in the status request itself — using the user's browser as the cron engine. The polling continues to drive progress. No more silent stalls.
* Fix 3 (JS defensive) : the progress modal handles `total = 0/undefined/NaN` by showing `…` until the first status poll. Stall detection client-side after 60s shows a hint to the user. AJAX timeout extended to 120s for large-site planning.
* Fix 4 (resume-on-reload safety) : if the user resumes an existing task, the response now includes the original `total` (was missing before, which caused the same "undefined" bug on tab reload).

= 1.1.57 =
* **Fix**: Search Console Overview tab stuck on `Clicks: 0 / Impressions: 0` even after a successful sync. The auto-sync trigger logic was buggy.
* Root cause: the auto-sync only fired when BOTH KPIs and indexation were empty. If indexation was already populated (by an earlier cron, manual sync, or background job), the condition `!hasIndex && !hasKpis` evaluated to `false` and the sync never ran — leaving the analytics KPIs forever at 0 even though the database had no analytics rows.
* Fix: auto-sync now triggers based on KPIs alone (`!hasKpis`). Indexation status is independent of analytics rows — they come from different backend tables and pipelines, so we can't infer one from the other. Now any user with empty analytics gets an automatic sync on first page load.

= 1.1.56 =
* **Fix**: "Could not resolve secondary URL to a local page" when clicking "Set canonical" in the Cannibalization tab. The resolver was relying solely on `url_to_postid()`, which silently fails for the WooCommerce Shop page (`/boutique/`, `/shop/`, etc.), the front page (`/`), and pages with custom permalinks.
* New centralized helper `resolve_url_to_local()` with cascading fallbacks: native `url_to_postid` → front page → blog page → WooCommerce Shop/Cart/Checkout/My-Account/Terms via `wc_get_page_id()` → `get_page_by_path()` for slug lookup → `/product-category/<slug>/`, `/category/<slug>/`, `/tag/<slug>/` for terms. Now correctly resolves `/boutique/` → Shop page ID, `/` → front page ID, etc.
* Used by `set_canonical`, `set_canonical_bulk`, and `resolve_url_to_entity` (Indexation tab). The cannibalization "Set canonical" button now works for the homepage and the Shop page, which are the two most common cases of cannibalization on a WooCommerce store.

= 1.1.55 =
* **Fix critical** : after reconnecting Google Search Console, the Overview tab stayed stuck on "Processing…" with empty KPIs (—) even though the server was correctly syncing thousands of rows in the background.
* Root cause: **cache poisoning** in the Search Console overview cache. The cache key included the period (`essiow_gsc_overview_cache_28`, `_90`, etc.), but the invalidation only deleted the unsuffixed key (`essiow_gsc_overview_cache`). On reconnect, the first overview fetch returned KPIs at 0 (sync not finished yet) and got cached for 1 hour — every subsequent fetch served the empty cache, never updating despite the data arriving in the database.
* Fix 1: new `invalidate_overview_cache()` helper that deletes ALL period-suffixed cache keys (`_1`, `_7`, `_28`, `_90`, `_180`, `_365`, `_480`). Called by all 4 places that previously did the broken single-key delete: `ajax_disconnect`, `ajax_sync`, `ajax_select_property`, `cron_nightly_sync`.
* Fix 2: JS `loadScOverview()` now accepts a `force` flag that bypasses the PHP cache. Used after the auto-sync triggered when KPIs are detected as empty, and after the manual "Refresh stats now" button — guarantees the post-sync fetch always sees fresh data, never the old cached zeros.

= 1.1.54 =
* **Fix definitively**: the GSC quota toast that kept appearing during Product / Category optimizations is now suppressed outside the Search Console tab.
* Root cause analysis: the auto-inspection background batch (50 URLs) re-fired on every table re-render after an optimization, hit the exhausted Google quota, and showed the toast — even though the user wasn't on the indexation tab. The 1-hour server cooldown was only set if **100%** of the batch errored; in practice GSC often returns 49 errors + 1 success, leaving the cooldown unset and the next run re-triggering the toast.
* Fix 1: **Toast confined to Search Console tab**. The auto-inspection still runs in background to populate badges, but the error toast only appears when `essiow.current_page === 'essiow-search-console'`. On Products / Categories pages, the cooldown is silently applied without the toast.
* Fix 2: **Cooldown threshold lowered to ≥50% errors**. Catches the realistic case (49/50 errors) — previously needed exactly 100%.
* Fix 3: **Cooldown duration extended to 6h** (vs 1h). Google's quota resets daily; a 1-hour cooldown was too short and caused the toast to come back after 1 hour of work.
* Fix 4: **Cooldown propagated immediately in the AJAX response** (`quota_cooldown: true, cooldown_until: ts`). The JS applies it without waiting for a page reload, so any subsequent inspection batch in the same session is short-circuited.

= 1.1.53 =
* **Major Graph view rewrite**. Visual link graph now shows the actual edges (lines) connecting pages — previously you saw nodes but no relationships.
* New: **Persistent edges** drawn as SVG lines between every pair of internally-linked pages. Subdued gray when idle, bold blue when a node is focused. Auto-redraws on pan/zoom. Capped at 1500 visible non-focus edges to keep large graphs (1000+ pages) responsive.
* New: **Click an edge to delete it**. Wide invisible hitbox (10px) makes 1px lines easy to click. Confirmation prompt, then the `<a>` wrapping is removed from the source page (anchor text preserved).
* New: **Permanently visible drag handle (🔗)**. Top-right of every node, opacity 0.55 by default, fully visible on hover or focus. Drag it onto another node to create a reciprocal link.
* New: **Click a node to focus it**. Highlights all its edges in blue, shows a status panel with title, URL, edit link, in/out counts and instructions. Re-click to defocus.
* New: **Type filters** (Products / Categories / Articles checkboxes) hide entire types — useful on big sites to inspect just the category-product mesh.
* New: **Toggle labels**. When zoomed-out on dense graphs, you can hide titles and keep only colored dots — much more readable.
* New: **Reorganize button** (🌀). Resets every node position to a fresh Vogel-spiral layout (golden-angle distribution = no visual rays). Preserved manually-dragged positions are wiped.
* New: **Visible legend** under the toolbar : 🔴 orphan / 🟢 hub / ⚪ normal + interaction help.
* New backend AJAX endpoint: `essiow_il_unlink_pair` (action). Removes `<a href="target">…</a>` wrappers from a source page's content, keeping the anchor text intact. Direction can be `a_to_b`, `b_to_a` or `both`. Used by the click-edge-to-delete flow.
* New: graph cache now exposes a flat `edges` array `[{from, to}, …]` (was previously dropped before caching). Allows the frontend to render the full mesh.

= 1.1.52 =
* Polish: rescue caps raised after real-world data (1.1.51 reduced orphans from 380 to 39 on a 1156-page store, score 87 → 99/100). PASSE 0 cap raised from 8 to 12 (per-source orphan absorption), PASSE B cap raised to 15 (final safety net).
* New: **PASSE B² — last resort**. If after PASSE 0 + PASSE B + main loop an orphan is STILL not covered (its entire fallback chain is saturated at 15), the orphan is forced onto the most active category of the site with NO cap. A category with 30 outgoing links is preferable to a permanent orphan. Closes the last 3% of edge cases.

= 1.1.51 =
* **Major rewrite of the automesh algorithm** based on a full audit. After 1.1.50, orphans were still surviving because of multiple subtle bugs identified in the chain.
* New: **PASSE Z — dead-end coverage**. Every page with no outgoing link is now FORCED to receive at least 1 outgoing target before the run ends, even if its semantic match is zero (last-resort: top active categories). Combined with PASSE 0 (orphan rescue first) and PASSE B (filet sécurité orphelines via chain), the algorithm now guarantees ≥1 incoming AND ≥1 outgoing for every page after a single run.
* Fix critical: **silent injection failures**. Previously, when `_inject_at_smart_position` returned `changed:false` (anchor not found in source content, anchor inside an existing `<a>`, anchor inside an HTML tag), the link was abandoned silently — meaning a planned rescue could fail without any retry. Now we fall back to the "Voir aussi" inline injection mode, which is guaranteed to succeed. Every planned target now becomes a real link.
* Fix: **double-counting of orphans_resolved and deadends_resolved**. Previously these counters were incremented in multiple passes (PASSE 0 + PASSE B + final loop). Now they are computed exactly ONCE at the end via `will_receive_incoming` / `will_emit_outgoing` sets.
* Fix: **anchor registry pollution**. `semantic_append` was being recorded as a phantom 4th key in the anchor type ratios, breaking the 10/35/55 diversity calculation. Now mapped to `semantic` for registry purposes.
* Fix: **PASSE B redundancy resolved**. PASSE B used a single-source picker (`_pick_rescue_source`) inconsistent with PASSE 0's chain. Both now use the same multi-source chain with a relaxed cap (+2) — orphans abandoned in PASSE 0 get a second chance via the same logic, not a different one.

= 1.1.50 =
* **Fix critical** : the orphan rescue PASS 0 (introduced in 1.1.49) was being **silently overwritten** by the main planning loop. When a category was used as a rescue source for orphan products, its `per_page` entry was created with the rescue targets — then the main loop re-assigned `$per_page[$sig] = [...]` with its own MUST/SHOULD candidates, **erasing every rescue**. This explained why 1.1.49 only resolved -9 orphans instead of -300+. Now the main loop merges with existing rescue targets, respects remaining quota slots, and skips already-rescued sigs to avoid duplicates.
* Fix: pages already saturated (8+ existing internal links) are no longer skipped if they have rescue targets planned — the no-orphan guarantee bypasses the saturation skip.
* Fix: deadends counter no longer over-counts (only increments when actual targets are merged into the plan).

= 1.1.49 =
* Fix: **Orphan rescue now runs FIRST**, before the main planning loop. Previously the rescue pass executed after categories had already filled their 5 MUST/SHOULD slots, leaving only 2 rescue slots per source — so a single click resolved barely 8% of orphans. Reordered: orphans get priority allocation with a per-source cap of 8, the main plan runs second.
* New: **Multi-source fallback chain** for orphan rescue. Each orphan now has an ordered list of candidate sources (parent category → sibling categories → topical articles → top 3 most active categories → product hubs). If one source is saturated, the chain tries the next one — guaranteeing every orphan finds a free slot somewhere. Replaces the previous single-source picker that gave up on the first saturation.
* Improvement: rescue cap raised from 7 to 8 targets per source, dedicated to orphan resolution exclusively (the main plan still respects the 5-per-page rule for non-orphan links).

= 1.1.48 =
* New: **No-orphan-left-behind** pass at the end of every automesh run. Any orphan that wasn't covered by the main planning is automatically rescued — its parent category (for products), nearest sibling (for categories), or the most active category (last resort) is forced to add a link to it. Combined with relaxed quotas (+2 above the 5-per-page cap when needed), the run guarantees ZERO orphans remain after a single click.
* Fix: **Category MUST targets prioritized for orphans first**. The previous algorithm sorted potential MUST products by their existing incoming-link count descending — which meant orphan products (in=0) were ALWAYS at the bottom and never picked. Categories now boost orphans (+10 000 points) before sorting by title similarity. Single-handedly resolves the majority of orphans in 1 run.
* New: **Relaxed-threshold fallback pass** for pages with no semantic match. If the strict Jaccard threshold (0.10) returns zero candidates, we relax to 0.03 and pick the closest category, article and product. Last resort = the most active category of the site (proxy for homepage). Guarantees at least 1 outgoing link for every page.
* Improvement: per-target incoming cap (30 new links/run) still enforced, but the orphan rescue pass bypasses the per-page-output cap by up to 2 extra links — the no-orphan guarantee takes priority over the conservative 5-per-page rule.

= 1.1.47 =
* Fix: **GSC quota toast no longer appears when running a product/category optimization**. The auto-inspection batch was firing on every page re-render, hitting the exhausted quota repeatedly. Now : runs once per session per page, stops trying after the first full quota hit, and the toast wording clarifies it is only about indexation status (not optimization).
* New (Automesh): **Anchor registry pre-loaded from existing content**. Before run 1, Essiow scans every existing internal link on the site and tallies anchor types (exact / partial / semantic) per target. The diversity check therefore works from the very first automesh — no risk of suddenly creating 50 exact-match anchors because the registry was empty.
* New (Automesh): **Per-target incoming cap of 30 new links per run**. Prevents super-popular targets (a top category) from absorbing all the link juice in one go. Beyond 30 incoming planned, the algorithm picks the next priority target instead. Avoids over-optimization patterns Google penalizes.
* New (Automesh): **Backup persistence in wp_options**. The 6-hour transient expiry no longer prevents reverting a run. Backups are mirrored to `essiow_il_automesh_last_backups` option, so the Revert button still works months after.

= 1.1.46 =
* New: **🔮 One-button Automesh on the Internal Links → Graph tab**. The button appears at the top of the graph and runs a complete topical-cluster mesh across the whole site in one click. No setting to configure.
* The algorithm follows current Google + 2026 SEO best practices :
  - Hub-and-spoke hierarchy (products → category parent + 2 siblings + 1 article + 1 cross-cat ; categories → 3 top products + 2 sibling cats ; articles → mentioned products + similar articles + 1 category)
  - Quota proportional to content length (1 link / 250 words), capped at 5 new links per page per run for predictability
  - Anchor diversity tracked globally with target ratios 10/35/55 (exact / partial / semantic) — beyond 15% exact for any single target, the algorithm switches to partial/semantic
  - Anchor placement in the FIRST third of content (Reasonable Surfer model)
  - Skip if already linked, if anchor would land in a <a> tag or HTML attribute, if total page links >= 100 (dilution), or if in-content links already >= 8 (saturation)
* New: **Preview before run** — a modal shows projected new links, orphans resolved, dead-ends resolved, mesh score before → after, average click depth before → after, estimated time. No surprise.
* New: **Backup auto-created** for every modified page (post_meta `_essiow_il_backup_<hash>`) and one-click **Revert** button at the end + permanent option to revert the last run from the modal.
* New: **Async cron worker** (batches of 20 pages) like the bulk optimize pattern. Quitting the page does not crash — the run continues server-side and the modal resumes when re-opening.
* New: **Auto-refresh of graph + mesh score** at completion — no manual reload needed.
* New: **30+ FR strings translated** for the new automesh UI.

= 1.1.45 =
* Fix: **Indexation badges flickering back to "Erreur"** after a few seconds. The JS auto-inspection batch was overwriting the in-memory badge with "error" status returned by failed GSC calls (quota exhausted, API timeout). Now the JS keeps the previous valid badge when an inspection result has status=error — same logic as the server-side fix in 1.1.44. A discreet toast informs the user when the GSC quota is exhausted instead of polluting the UI with red badges.

= 1.1.44 =
* Fix critical: **Front-end critical error on product pages** when one of the schema/canonical hooks raised an exception. All four wp_head emitters (Product schema, BreadcrumbList schema, Article schema, FAQ schema, custom canonical) are now wrapped in try/catch — a bad page can no longer take down the entire front-end. Errors are logged via error_log() when WP_DEBUG is on, never propagated to the visitor.
* Fix: defensive  and  guards before calling WC-only conditional functions in the schema emitters.
* Fix: **Indexation column showing "Erreur" on every product**. When GSC URL Inspection fails (quota exceeded, timeout, transient API error), the per-URL result has . The plugin was overwriting the cached  with this false status. Now we KEEP the previous valid status when the new fetch errored, only updating on real Google verdicts.
* Migration: a one-time admin_init cleanup deletes any existing  rows in postmeta + termmeta, so the next auto-inspection batch on Products / Categories pages starts fresh.

= 1.1.43 =
* UX: **Site SEO score absorbed into the existing stats row.** No more separate full-width card with empty space — the score now sits as the first card in the same row as Available credits, Products optimized, Categories optimized, Articles by Essiow. Colored top border (green/yellow/red) keeps the level visible at a glance.

= 1.1.42 =
* UX: **Site SEO score card simplified** — removed the breakdown list and the descriptive paragraph. Only the score on 100 with its colored badge remains on the Dashboard.

= 1.1.41 =
* New: **Global site SEO score** on the Dashboard, computed locally on 100 points from 9 objective factors :
  - 20 pts — % of products optimized by Essiow
  - 15 pts — % of categories optimized
  - 10 pts — Essiow blog articles published (3 = max)
  - 15 pts — % of inspected URLs that Google has indexed
  - 15 pts — Internal mesh score (uses the existing graph cache)
  - 10 pts — JSON-LD schemas active
  -  5 pts — IndexNow auto-ping active
  -  5 pts — /llms.txt AEO toggle active
  -  5 pts — Search Console connected
  Big colored card (green ≥ 70 / yellow ≥ 40 / red < 40) + breakdown of every factor with its earned points / max. Recomputed on every Dashboard load — no API call, all data already on the site.
* Fix: **Indexation table labels in French** — Indexed / Crawled not indexed / Discovered / Excluded / Error were rendered hardcoded in JS. Moved through `wp_localize_script` strings (`s.idx_*`).
* Fix: **Google coverage_state strings translated** — "Submitted and indexed", "Crawled - currently not indexed", "URL is unknown to Google", "Discovered - currently not indexed", "Page with redirect", "Soft 404", "Not found (404)", "Server error (5xx)", and 6 more variants. Map applied at render time via `localizeCoverage()`.
* Fix: **Type labels translated** — Product / Category / Article / Page in the indexation table type column now use the WP locale.
* Fix: cleaned remaining `\n` artifacts in `essiow-fr_FR.po`. **783 entries**, **50.7 KB compiled .mo**, zero `#-#-#-#-#` marker, zero msgfmt error.

= 1.1.40 =
* Critical fix: **`msguniq` left 43 conflict markers `#-#-#-#-# essiow-fr_FR.po (Essiow) #-#-#-#-#` directly inside `msgstr` strings** of the French .po file. WordPress was rendering them in the UI ("Credits disponibles #-#-#-#-#... Crédits disponibles", "Non classée #-#-#-#-# Non classé", "Générer l'article #-#-#-#-# Générer un article", etc). Each conflict resolved automatically by picking the longest non-empty alternative, then leading/trailing `\n` markers stripped, then comments removed. Result : zero `#-#-#-#-#` in the .po, .mo recompiles clean (no warnings, no fatal errors), 648 valid translations.

= 1.1.39 =
* New: **📡 Bulk Ping button on Products + Categories** alongside 🚀 Index selection. Two clear options : light IndexNow ping (instant, no Google) vs full request indexing (IndexNow + sitemap + URL Inspection refresh).
* Fix: **Issues panel labels/descriptions/suggestions are translated**. The Flask backend returned hardcoded English strings ; the plugin now intercepts the response and replaces them with `__()` translations on the way out. "Crawled but not indexed", "Discovered but not crawled", "Excluded by Google", "Indexation errors" + their descriptions and suggestions all appear in the WP locale.
* Fix: **"Dashboard" and "Blog" submenu items** were registered without `__()` calls, so they stayed in English even with French locale. Both now translatable.
* Fix: **19 fuzzy translations unflagged** in the .po file. WordPress ignores `#, fuzzy` entries by default — the FAQ answers ("Yes. The Pause...", "Yes. Since 1.1.30...") and several other long strings were never displayed in French. Removed all fuzzy flags.
* New: **Plugin description rewritten** — sales-focused, benefit-driven, no technical jargon. Explains what Essiow does for the shop owner, not how it works internally. Added the new features (cannibalization fix, internal-link graph, /llms.txt for AI search engines, GSC-driven optimization, Bulk indexation).
* New: **20+ FR translations added** for the bulk-ping labels + Issues groups. Total : **748 entries**, **81 KB .mo**.

= 1.1.38 =
* **CRITICAL FIX: `load_plugin_textdomain()` was never called.** The .po/.mo files in `/languages/` were ignored by WordPress entirely — that's why the plugin stayed in English even when the WordPress locale was French. Now properly loaded on `plugins_loaded` so every translated string in the plugin (Search Console tabs, Help guide, Indexation tab, Modules cards, Cannibalization actions, FAQ, etc) appears in the WP locale.
* New: **+196 French translations added** — Help guide modules (Getting started, Modules, Recommended workflow, Ping vs Request indexing, Pricing, Tips, FAQ), Search Console tabs (Overview, Indexation, Opportunities, Issues, Performance, Audit, Submission), all Indexation column states, all Cannibalization actions, all Internal Links labels, all bulk action labels. **730 total entries** in `essiow-fr_FR.po`, **70 KB compiled .mo**.
* Fix: **Internal Links graph stops working after creating a link** — fully rewritten render :
  - Positions are now preserved per-sig (drag positions survive ilLoad refreshes).
  - Cleanup of stale positions for deleted pages.
  - Handlers bound with `$(document)` event delegation instead of `$canvas` references → survives canvas DOM rebuilds.
  - `ilGraphBindHandlers()` is now idempotent (`ilHandlersBound` flag) and called once at first render.
  - The handlers re-fetch the canvas's `getBoundingClientRect()` on every drag — the rectangle was stale after re-render.
  - Removed obsolete `setTimeout` rebinds on tab-switch.
* New: **Smart fuzzy local matching** for the "🔍 Find matching pages" modal — produit/catégorie/article search via WP `wpdb` directly, with accent normalization (`remove_accents()`) and FR/EN/ES stopword filter. Each match now displays `N tokens match` + a one-click ✨ Optimize button targeting the original GSC query.

= 1.1.37 =
* New: **Universal spinner state** for every async action button — Ping, Request indexing, bulk Ping/Index, Re-optimize, Rotate API key, Disconnect. The button shows a CSS spinner (and stays disabled) until the server responds, so the user always knows an action is in flight.
* New: **Smart query → matching** with fuzzy token search. The "🔍" button on Performance / Striking distance now also returns local WordPress products / categories / articles whose titles contain ANY of the query tokens (after stop-word filter and accent normalization), not just GSC-tracked pages. Each match has a score = number of tokens found + a one-click ✨ Optimize button that targets the original query.
* New: **Drag-to-link in the Internal Links graph (Miro-style)** — hover any node and a 🔗 handle appears top-right. Drag it to another node : a dashed SVG line follows the cursor + the target node highlights green. Drop → confirmation modal → Essiow injects reciprocal anchor links in both contents.
* New: **Bulk Ping + Request indexing in the Search Console → Indexation tab**. Two new buttons next to "Re-check selected" — pick rows with the existing checkboxes, then ping or request indexing on all of them in one server round-trip.
* New: **API key rotation from Settings**. New endpoint `POST /license/rotate-api-key` — old key invalidated immediately on the server, new key auto-saved in `essiow_api_key`. Use case : suspected leak, or routine rotation hygiene.
* New: **Disconnect this site** button — clears the local API key + connected flag without invalidating the key on the server (so it can be re-pasted later). Combine with rotation for a full re-pair.
* Fix: **Internal mesh score panel** redesigned — left side shows the big score in a colored card (green/yellow/red), right side shows the 5 weighted factors with their points / max as a clean list. Replaces the previously broken inline-text layout.
* Fix: **Help page hides "Connect Search Console" when GSC is already connected** — replaced by a green "Connected ✓" + "Open Search Console" button.
* Fix: **Typo "Restaurér" → "Restaurer"** in the French translation file (`languages/essiow-fr_FR.po` lines 380 and 397). Visible everywhere the Restore button appeared in French.
* Fix: **`audit_seo_factors()` and `audit_category_factors()` now static** — the search-console resolver was instantiating Essiow_Products / Essiow_Categories per row, re-registering all action hooks each call. Performance regression fixed.
* Fix: **Cannibalization secondary URLs in French** (`/categorie-produit/`) now correctly resolve to terms when setting canonical (the legacy code only matched `/product-category/`).
* Improvement: **300+ new French strings translated** (1.1.30 → 1.1.37 features). The plugin is now fully usable in French — Help & Guide, Cannibalization actions, Internal Links module, Pricing tooltips, Bulk action labels, FAQ.

= 1.1.36 =
* Fix critical: **`essiow_inspect_urls` AJAX action name corrected to `essiow_gsc_inspect_urls`** — the auto-batch URL Inspection on Products and Categories pages was failing silently for every user. Now correctly fires and populates the indexation badges in real time.
* Fix: **`audit_seo_factors` and `audit_category_factors` are now static** — they were being called from `Essiow_Search_Console::resolve_url_to_entity()` which instantiated `Essiow_Products`/`Essiow_Categories` per row, re-registering all action hooks each time (memory + duplicate-handler bug).
* New: **Help & guide menu** — full submenu with 7 tabs : Getting started, Modules, Recommended workflow, Ping vs Request indexing, Credits & pricing, Tips, FAQ. Strictly aligned with the actual features of the plugin (no fictional content).
* New: **Help link injected on every Essiow page** — a discreet `❓ Help` button appears in the top-right corner of each header, one click away from the dedicated guide.
* New: **Pricing transparency in the Audit tab** — the Auto-fix alts description now reads from the live cost map and shows the actual credit cost.
* New: **Pricing rebalanced**:
  - Alt text generation : `CREDITS_PER_ALT_TEXT = 2` (was implicitly billed as a full product = 1 — the Vision call cost is now accurately billed).
  - Indexing actions (Ping IndexNow + Request indexing + URL Inspection batches + sitemap submit) : free — they don't call the AI.
  - Image audit, llms.txt toggle, schema emission, internal-link suggestions, internal-link graph rendering, internal mesh score : free.
* New: **`/credits/balance` returns the cost map** so the plugin can display realistic prices everywhere without round-tripping the config.
* New: **`CreditService._costs()` centralized** — single source of truth for all credit costs across normal billing, Shopify usage billing, and balance display. Removes 3 duplicated cost dicts.
* Improvement: **"Optimize a product/category"** dashboard quick-link card replaced by a direct **Help & guide** card so new users can find the workflow guide instantly.

= 1.1.35 =
* Fix: **Article generation now shows the percentage**. The view's existing progress bar had an `--indeterminate` CSS animation that ignored width updates, and the JS was looking for a non-existent `#essiow-blog-progress-text`. Both fixed — `0% → 100%` now ticks visibly with status label and elapsed time.
* Fix: **Internal Links titles now decode HTML entities** (`&#8211;` → `–`, `&amp;` → `&`, etc) — applied via `html_entity_decode()` server-side before caching the graph.
* Fix: **Lost rankings table now renders fully** with a new "Clicks lost" column. The Flask service now returns `previous_clicks`, `current_clicks`, `impressions`, `potential_clicks` for each lost-ranking page so the user sees the actual revenue impact, not just an abstract delta.
* New: **Floating "Optimizations" panel** (bottom-right) replaces the silent toast. Click "Re-optimize" → a row appears with name + progress bar + status + elapsed time. When done : button "View content" opens the editor + score badge. Multiple optimizations stack in the panel. Minimize/dismiss available.
* New: **Bulk actions in Existing Articles** :
  - Checkbox per row + "Select all"
  - 📡 Ping selected · 🚀 Request indexing selected
  - Filter dropdown : All / Essiow only / Other / Low score (<40)
* New: **Bulk actions per Issue group** (Crawled-not-indexed / Discovered / Excluded / Error) :
  - Checkbox + "Select all"
  - 📡 Ping all · 🚀 Request indexing all · ✨ Re-optimize all (sequential 1.5s spacing)
  - Auto-resolves the URL → product/category/article and fires the right optim endpoint.
* New: **Bulk for Lost rankings** (Ping / Request indexing on selected rows).
* New: **Performance tab actions per query** :
  - 🔍 Find matching pages (existing query-explore modal)
  - ✨ Generate article for this query (redirects to Blog with keyword pre-filled via `?essiow_keyword=…`)
  - 🎯 Optimize matching products (opens the matching-pages modal where each result has its own Re-optimize button)
* New: **Internal Links graph — Miro-like overhaul** :
  - **Pan** by dragging the background, **zoom** with the mouse wheel (zoom-to-cursor), **drag** individual nodes
  - Toolbar : `+` / `−` / `⟲ Reset view`
  - **Click two nodes to create a reciprocal internal link** — the server algorithm finds the strongest shared keyword and wraps it as `<a>` in both contents (or appends a "Voir aussi" paragraph if none match).
  - **Internal mesh score / 100** computed from 5 factors : `% pages with ≥1 incoming` (40 pts), `% pages with ≥1 outgoing` (30 pts), `hub ratio 5-20%` (10 pts), `avg in / out ≥ 2` (20 pts).
  - Node now shows `⬅ in / out ➡` mini-stats inline.
  - Layout clusters nodes by type : products on the left, articles in the middle, categories on the right (no more chaotic spiral).
* Improvement: **`runInlineOptimize` panel persists state** across optimizations — start 5 in a row, watch them complete one by one, dismiss each individually.

= 1.1.34 =
* Fix: **Cannibalization actions now update the UI live**. After "Set canonical", the secondary row fades out instantly, the unresolved counter updates, and the whole block removes itself once only the primary remains. Toast confirms the action with the destination URL. No more stale buttons that look unchanged.
* New: **Cannibalization bulk actions** :
  - Checkbox per pair + "Select all"
  - "🔗 Set canonical on selected" → applies the consolidation to every secondary in every selected pair (one server round-trip)
  - "✕ Dismiss selected" → hides every selected pair from future lists
* New: **Cannibalization filter** — the bulk bar shows a live "N unresolved" counter and a "Show dismissed" link. After resolving everything, an empty-state cheers ✓ with a "Restore previously dismissed" recovery action.
* New: **Promote re-renders the whole block** instantly — the new primary gets the green "Primary" badge, every other row gets the "Set canonical" button pointing to the new primary. No more orphaned "Confirm as primary" button.
* Improvement: **Set canonical also marks the pair as resolved** server-side (`essiow_resolved_cannibal` option) — the next opportunities refresh excludes it automatically. Combined with the live row removal, the user never sees the same resolved pair twice.
* Improvement: clearer **Primary badge** (green) on the primary row + visual distinction (green tint) so the choice is unambiguous.

= 1.1.33 =
* Fix: **Internal Links tabs now switch correctly**. The tab system was looking for `#tab-X` IDs while the view used `essiow-tab-il-X`. Tabs are now generic — `data-tab-prefix` on the nav drives the lookup, supporting both Search Console (`essiow-sc-`) and Internal Links (`essiow-tab-il-`) conventions.
* Fix: **`undefined: <date>`** string on Internal Links → added the missing `last_scan` translation key + 60+ other translatable strings used by the new modules.
* Fix: **Dashboard GSC stats display** — KPI block stayed at "…" because the JS was reading `resp.data.kpis` instead of `resp.data.data.kpis` (Flask payload is wrapped). All four KPIs (clicks/impressions/CTR/avg pos) and all four opportunity counters now render correctly.
* New: **Ping vs Request indexing — two distinct buttons everywhere** :
  - 📡 **Ping (IndexNow only)** : light, instant notification to Bing/Yandex/Naver/Seznam. No tab opens, no Google. Runs in 1 second.
  - 🚀 **Request indexing (full)** : IndexNow + sitemap re-submit + URL Inspection refresh + opens GSC URL Inspector for the manual "Demander indexation" click on Google.
  Both are now exposed on every actionable URL row : Products, Categories, Striking distance, Low CTR, Lost rankings, Issues URLs, Articles list, Indexation tab.
* New: **Auto-clear `Indexing requested` state** — when a URL is later detected as `indexed` by GSC URL Inspection, it's automatically removed from `essiow_indexing_requests` and the post_meta `_essiow_indexing_requested_at` is cleared. The 🚀 button stops being green-checked and becomes available again.
* New: **Indexation tab refondu** — each row now shows the post Type (🛒 Product / 📁 Category / 📝 Article / 📄 Page) + SEO Score + an `✨ Optimize` button that routes via the smart re-optimize handler (so the AI re-runs the full optimization on the matching product/category, addressing every missing factor from the SEO audit). The legacy "Inspect ↗" button is now a 🔎 icon next to Ping/Request.
* New: **Article generation : excludes already-covered GSC keywords**. The Blog page no longer suggests queries that already match an existing article's `_essiow_article_keywords` post_meta (exact match + fuzzy substring match for keyword stems ≥ 5 chars). New opportunities surface as you publish articles.
* New: **Configurable GSC period** — 24 hours / 7 days / 28 days / 3 months / 6 months / 12 months / 16 months (the GSC max). Period selector at the top of the Search Console tab, applies to KPIs, opportunities, and indexation stats. Per-period cache so switching is instant.
* Improvement: **Cannibalization secondary URLs handle French slugs** — `/categorie-produit/` (French permastruct) now correctly resolves to `product_cat` terms when setting canonical or auto-clearing indexing state, in addition to the English `/product-category/`.
* Improvement: **Indexation table action column** widened to 240px to fit the Optimize + Ping + Request + Inspect buttons without wrapping.

= 1.1.32 =
* New: **Cannibalization is now actionable** — each row gets "Set canonical → 🏆", "Promote" (change which page is the primary), and "Dismiss" buttons. "Set canonical" stores `_essiow_canonical_url` on the secondary post/term and emits a custom `<link rel="canonical">` that overrides Yoast/Rank Math. Dismissed pairs are filtered out of future opportunity lists.
* New: **Smart Re-optimize routing** — clicking "Re-optimize" on a striking-distance / low-CTR / lost-ranking row now resolves the URL server-side via `essiow_resolve_url`, then triggers the actual product/category optimization inline (no more dead-end redirect to an empty Blog form). The GSC query is passed as the focus keyword so the AI targets it directly. For articles, the editor opens with the right context.
* New: **Server-side URL resolver** (`/wp-ajax/essiow_resolve_url`) returns `{type, id, name, edit_url}` for any frontend URL — used by the Re-optimize and Cannibalization actions.
* New: **🚀 indexing button on every actionable row** (Striking distance, Low CTR, Lost rankings) for one-click submit-to-IndexNow alongside the optimize button.
* Improvement: **Better potential-clicks math** — striking distance now uses the real CTR-by-position curve (pos 5 ≈ 5%, pos 1 ≈ 30%). Formula : `max(0, impressions × (target_ctr − current_ctr))` — accurately reflects the realistic gain after a successful re-optimization.
* Improvement: **Cannibalization primary picker** — the page presented as 🏆 is now the one with the highest `clicks×10 + impressions` score (revenue-weighted), not just the most-impressed.
* Improvement: **Better empty states for GSC-disconnected** — Opportunities and Issues tabs show a centered hero CTA "Connect Search Console →" instead of a tiny disabled message. Same connect button works from any tab.
* Improvement: **Indexation column adapts to GSC state** — when GSC is not connected, the column shows a clickable "Connect GSC" mini-link instead of a meaningless "—". Inspection batches don't fire at all without GSC connected (saves API quota).
* Improvement: `gsc_connected` exposed to JS via `wp_localize_script` for clean conditional logic across all UI.

= 1.1.31 =
* New: **Internal Links module** (new submenu) — graph + orphan detection + dead-end detection + reciprocal click-to-link generator. Pick page A and page B, Essiow finds the strongest shared keyword and wraps it as an anchor in BOTH directions, then saves both pages. If no shared keyword, an inline "Voir aussi" paragraph is appended. Includes a graph view with hubs (green) and orphans (red).
* New: **Dashboard refondu** — drops the "Recent errors" panel, adds live GSC KPIs (clicks, impressions, CTR, avg position over 28 days) and an opportunities snapshot (striking distance count, low-CTR pages, cannibalization, indexation issues), all linkable to the Search Console tab.
* New: **Blog page refondue** — list of all existing articles with a SEO score (words, headings, meta, internal links, featured image), direct edit + 🚀 indexing buttons. Above the form, **GSC topic suggestions** appear when GSC is connected: striking-distance queries become 1-click chips that pre-fill the keywords.
* New: **GSC-aware article generation** — `build_article_prompt()` now accepts `gsc_context`. The Flask backend matches your typed keywords against your real GSC queries (last 28 days) and injects `top10` / `striking` / `beyond` buckets into the prompt so the AI writes the article around the actual searches your audience makes.
* New: **Persistent "Indexation requested" state** — the 🚀 button now stays green-checked after click. The state is stored in `essiow_indexing_requests` option and re-applied on every page load. No more confusion about which URLs you already submitted.
* New: **Per-row 🚀 indexing button** + **bulk "Index selection"** in Products and Categories. Multi-row selection sends all URLs in a single IndexNow batch ping.
* New: **Real-time indexation status** for Products and Categories — when GSC is connected, the page auto-fires URL Inspection in batches of 50 for any row showing "—", populates `_essiow_index_status` post_meta/term_meta, and updates the badge in place (Indexed / Crawled-not-indexed / Discovered / Excluded).
* New: **Server-side pagination** for Products (50 per page, prev/next + jump buttons). The list auto-loads on page open — the "Scan products" button is replaced by a discreet "Refresh" link.
* Improvement: stats on Products page now use **global counts** (total + optimized across the whole DB) instead of the current-page subset. The dashboard mirrors them.
* Cleanup: removed the in-admin "Error log" panel from Settings and the `essiow_last_errors` storage. Plugin now logs only to PHP `error_log()` when WP_DEBUG is on.
* Cleanup: dropped redundant always-visible "Auto-fix alts" button (kept only the contextual one inside the audit result table).

= 1.1.30 =
* New: **Enriched SEO score** — 16 factors weighted on 100 points (description length, structured headings, internal links, meta title/desc length zones, focus keyword, image count + alt coverage, attributes, categories, tags, reviews, SKU, schema, Essiow-optimized flag). Replaces the previous 9-factor score.
* New: **SEO criteria injection into AI prompts** — the audit detects what's missing on a page and tells the AI explicitly to address each gap during optimization. The AI now sees a "to-do list" alongside the buyer-intent and GSC blocks. Result: optimizations consistently fix what the audit flags.
* New: **Auto-fix alt text via AI Vision** in the Audit tab. Scans up to 20 product images without alt and generates natural multilingual alt texts via `gpt-4o-mini` Vision (1 credit per image).
* New: **Query → matching products** modal — a 🔍 button next to each striking-distance query opens a popup listing the WooCommerce products and pages that could realistically rank for it.
* New: **Request indexing** button on every issue URL and on striking-distance rows. One click pings IndexNow + re-submits the sitemap + refreshes the URL Inspection cache + opens the GSC URL Inspector.
* New: **/llms.txt for AEO** (ChatGPT, Perplexity, Claude). Standardized markdown catalog served at the site root, exposing categories, recent products and blog posts. Toggle in Audit tab.
* Improvement: **API key persistence on plugin update** — replaced the file-checksum-deletion-of-connection with an async re-validation pattern. The user no longer has to re-paste their key on every release.
* Improvement: **Auto-load on Products / Categories pages** — the lists scan on page open instead of waiting for a manual click.
* Improvement: **Bulk skip already-optimized items silently** — bulk runs ignore items that already have `_essiow_optimized` set unless `force=1`. No more re-spending credits on the same product twice.
* Improvement: cleaned up duplicate datetime imports in the Flask query-matches endpoint.

= 1.1.29 =
* New: **AI re-optimize via Search Console data** — when a product or category is optimized while the GSC connection is active, the prompt now includes the REAL queries this page ranks for (top 10 to preserve, striking distance to push, beyond-page-2 opportunities) plus a CTR alert if the title isn't converting. Surgical optimization vs generic.
* New: **Opportunities tab** in Search Console with 4 actionable insight cards :
  - ⭐ Striking distance keywords (pos 11-20) with potential clicks/month
  - 📉 Low CTR on high-impression pages (current vs expected CTR)
  - 🚫 Cannibalization detection (multiple pages competing for same query)
  - 📊 Lost rankings (pages whose avg position dropped 5+ vs previous period)
  Each row has a "Re-optimize" button that takes the user to the page editor.
* New: **Issues tab** — indexation problems grouped by category (Crawled-not-indexed, Discovered, Excluded, Error) with a concrete suggestion for each group + collapsible URL list.
* New: **Audit tab** — image SEO scan (missing alt text, oversized files), schema markup status, IndexNow status. Includes a "Test with Google Rich Results" link.
* New: **BreadcrumbList JSON-LD** auto-emitted on product and product-category pages. Helps Google show breadcrumbs in search results (rich snippet).
* New: **FAQPage JSON-LD** auto-detected on Essiow-generated articles when they contain a "Questions fréquentes" / "FAQ" H2 with H3 question / paragraph answer pairs. Eligible for FAQ rich snippets.
* New: **IndexNow batch endpoint** for sending many URLs in a single ping (used during bulk to avoid 50 small pings).
* New: 6 server-side endpoints — `/gsc/opportunities`, `/gsc/page-stats`, `/gsc/issues` and prompt service `build_gsc_section()` injection helper.

= 1.1.28 =
* New: Pause / Resume buttons during a bulk optimization. Pause stops the worker between items (the current item finishes naturally), Resume picks up where it stopped without losing the queue. The `[⏸ Pause]` button appears next to `Cancel` while running, switches to `[▶ Resume]` once paused.
* New: leaving the page during a bulk (refresh, navigation, tab close) now AUTOMATICALLY cancels the bulk via `navigator.sendBeacon()`. Items that had already been optimized stay saved in the database; the pending queue is dropped. The user must restart from scratch if they want to continue — by design.
* Removed: auto-resume on page load. Bulk tasks no longer survive page reloads — closing the tab is treated as an explicit cancellation. Closes a class of "phantom resume" UX bugs.
* New: server-side pause/resume endpoints (`essiow_bulk_*_pause`, `essiow_bulk_*_resume`) for both products and categories.
* New: `nopriv` cancel endpoint for the page-leave beacon (cookies aren't always sent on unload, so we use task_id ownership check via the active option instead of nonce).

= 1.1.27 =
* Fix: 503 errors from `admin-ajax.php` no longer leave Search Console KPIs at 0 forever. The data sync into Flask was already working (1561 rows committed in DB) but the follow-up `essiow_gsc_overview` call would 503 under Wordfence/Cloudflare load and the JS would just give up — leaving the user looking at 0 clicks / 0 impressions despite having real GSC traffic.
* Improve: new `postWithRetry()` JS helper with exponential backoff (1s → 2s → 4s → 8s) on 503 / 504 / 429 / network errors. Used by both the auto-load and the manual "Refresh stats now" button.
* Improve: auto-sync logic merged into `loadScOverview()` — the page now makes ONE overview call on load instead of two (was: load + check-if-empty as separate calls). Less admin-ajax noise = less Wordfence rate-limiting.
* Improve: clearer error toast when the WP server is overloaded ("Serveur surchargé · réessayez dans 30s") instead of a silent failure.

= 1.1.26 =
* Fix: Search Analytics now auto-tries every property variant and keeps the one returning the most rows. The previous behavior accepted the first 200 response even if it had 0 rows, which was wrong when the user has both a URL prefix property (potentially empty) and a Domain property (with all the data) — the Domain variant is now used automatically.
* Fix: Performance tab is no longer empty. New `loadScPerformance()` JS function populates it with the top queries + a dedicated "Striking distance" panel highlighting positions 11-20 (easy SEO wins).
* Improve: auto-sync at page load if no cache exists, so users land on populated KPIs without having to click "Refresh stats now" first.
* Server-side: detailed structured logging on every Search Analytics call (property tried, response status, row count) for easier diagnostics.
* New strings (top_queries, query, clicks, impressions, position, striking_hint, no_striking, etc.) so the Performance tab is fully translatable.

= 1.1.25 =
* Fix: "Indexation overview" no longer stays stuck on "Traitement en cours…" / "Processing…" when the cache is genuinely empty. Now shows "No URLs inspected yet — click 'Refresh stats now'" until data is populated.

= 1.1.24 =
* Cleanup: removed the "Change property" button and its dropdown picker UI from the Search Console connection card. With the auto-fallback added in 1.1.23 (server tries every property variant on a 404), the manual property selector is no longer needed in normal usage. The backend endpoints (`/gsc/properties`, `/gsc/select-property`) remain available for any future use.

= 1.1.23 =
* Fix: Search Console sync now automatically tries property variants (`sc-domain:` first, then URL-prefix, www, http) when the saved property URL returns 404 from the Search Analytics API. The first variant that responds 200 is silently saved as the new property — the user no longer has to pick the right one manually.
* Fix: surfaces Google's actual error message (e.g. "User does not have sufficient permission for site …") instead of the generic 404, plus a concrete remediation hint ("Vérifiez que vous êtes Owner ou Full user de la propriété, et que la vérification est complète").
* Fix: properties dropdown now hides `siteUnverifiedUser` properties (which always 404 on Search Analytics), shows the permission level next to each entry (`Domain · Owner`, `URL prefix · FullUser`), and sorts Domain properties first then by permission strength.
* Fix: JS access path on the sync response — was looking at `resp.data.data` (double-nested) which caused the toast to always show "0 rows · 0 URLs" even on a successful sync.

= 1.1.22 =
* Fix: Search Console sync no longer 404s when the GSC property is registered with a different format than the WP site URL (e.g. `sc-domain:` vs `https://`, with/without `www`, http vs https). The auto-pick now matches sc-domain first, then URL prefix variants (https/http × with/without www), then substring fallback. If nothing matches, the plugin asks the user to pick the right property manually.
* New: "Change property" button on the Search Console connection card. Click → dropdown of all your Search Console properties → select → save. The plugin remembers the choice and uses it for all future syncs.
* New: Flask endpoints `GET /api/v1/gsc/properties` and `POST /api/v1/gsc/select-property` powering the manual selector. The select endpoint security-checks that the property belongs to the connected user before saving.

= 1.1.21 =
* Fix: 1.1.20 OAuth flow was broken — server returned `auth_url` at the response root but the plugin read it from the `data` envelope. Standardized: every Search Console endpoint now returns `{success, data: {...}}`. Connecting Search Console now actually works.
* Fix: `cryptography` was missing from `requirements.txt`. AES-256-GCM token encryption would have crashed the GSC service at runtime. Added.
* Fix: cipher key now falls back to Flask `app.config['SECRET_KEY']` if neither `ESSIOW_GSC_KEY` nor `SECRET_KEY` env vars are set. Avoids hard-crash when the operator forgets the dedicated key.
* Fix: Indexation tab is no longer empty forever. The "Refresh stats now" button now sends a batch of priority URLs (recent products + categories + recent articles + homepage, ~50 URLs) to the SaaS for inspection — first click populates the indexation list immediately. The nightly cron continues rotating the full URL set within GSC quotas.
* Fix: indexation column added to Categories list (was products-only). Term meta `_essiow_index_status` is updated whenever URL Inspection runs and the URL matches a `/product-category/<slug>/` permalink.
* Fix: `is_connected()` early-return guards on `ajax_overview`, `ajax_indexation`, `ajax_inspect_urls` so users who haven't connected GSC yet see a clean "Search Console is not connected" message instead of an opaque API error.
* Fix: missing localized strings — `connecting`, `refresh`, `recheck`, `submit_sitemap`, `index_*`, `striking_distance`, `no_data_yet` — buttons stay in the user's language across the Search Console workflow.

= 1.1.20 =
* New: full Google Search Console + IndexNow integration. New top-level "Search Console" submenu in the Essiow admin with four tabs:
  * **Overview** — connection card with one-click "Connect to Google Search Console", four KPIs (clicks / impressions / CTR / avg position over 28 days, with delta vs the previous period), a 28-day clicks/impressions bar chart, an indexation pie, top 20 queries and top 20 pages tables.
  * **Indexation** — paginated list of every URL Google has seen on the site with its real status (`Indexed`, `Crawled not indexed`, `Discovered`, `Excluded`, `Error`, `Unknown`), last crawl date, and a "Re-check selected" bulk action that triggers the URL Inspection API on demand.
  * **Performance** — top queries and pages (28d). Striking-distance keywords (positions 11-20) are highlighted in orange — the easy SEO wins.
  * **Submission** — one-click sitemap submission to Google + IndexNow (Bing, Yandex, Naver, Seznam) with full submission history.
* New: `Indexation` column in the Products list. Every product row shows a colored badge for its real Google indexation status — green for indexed, orange for discovered/crawled-not-indexed, red for excluded, grey for unchecked.
* New: auto IndexNow ping on every publish/update (toggle in Search Console > Submission). Bing/Yandex/Naver/Seznam re-crawl within seconds with no quota and no setup. The verification key file is auto-served at `/<key>.txt` on the site root.
* New: nightly Celery job `app.tasks.gsc_nightly_sync` pulls Search Analytics + URL Inspection rotation for all connected sites.
* Architecture: Google OAuth is centralized on essiow.com (a single verified OAuth client for all customer sites). Refresh tokens are encrypted with AES-256-GCM and never leave essiow.com.

= 1.1.19 =
* Fix: single category optimization no longer reloads the page when it finishes. The 1.2 s `location.reload()` after a successful single optimize was killing every other concurrent in-flight task in the same tab — running 5 manual optimizations in parallel meant 4 of them were aborted by the first one's reload. The row's badge / score / status are now updated in place, exactly like single product optimize already does.
* Fix: "Resuming optimization in progress…" followed by "Task not found or expired" no longer appears after a normal page navigation. The resume detection now PROBES the server first (one quick status call) — only if the task is genuinely still `running` does the toast appear and polling start. If the task is gone (done, cancelled, transient expired), the resume is silently skipped.
* Fix: server-side auto-cleanup of `essiow_active_bulk_*` options when the bulk status endpoint sees the underlying task is missing or no longer `running`. Stale lock options can no longer survive a session — the next page load won't even probe.

= 1.1.18 =
* Fix: filtering products to "non-optimized" then clicking bulk no longer re-runs the whole previous batch. Before, the singleton lock would silently ignore the new selection and resume the previous task — so a 5-item filtered selection would re-trigger optimization on the original 50-item queue. Now any new bulk request with explicit IDs cancels the old running task and starts fresh; only an explicit resume (page reload with no selection) reattaches to an existing one.
* Fix: bulk no longer goes "all queued, nothing finishing" after the first item. The status endpoint had an 8-second staleness threshold for poll-driven processing, which fired during the first item's normal 15-25 s Flask call — so each subsequent poll started ANOTHER item in parallel, saturating PHP-FPM workers. Threshold raised to 45 s (longer than one item's processing time) and a per-task mutex transient now guarantees only one worker processes a given bulk at any moment, regardless of how many polls/cron events fire concurrently.
* Fix: "Task not found" no longer kills a running task during a transient race. The single-item and bulk pollers now tolerate up to 3 consecutive `not found / expired` responses before giving up — covers brief object-cache eviction or FPM worker recycling without the user seeing the row turn red mid-flight.
* Improve: single-item task transients now keep for 6 hours instead of 1, so optimizations launched then revisited after a long meeting still show their result instead of "expired".
* Improve: bulk polling interval bumped from 3 s to 5 s. With the per-task mutex preventing wasted parallel polls, slower polling means less admin-ajax noise on the host (less Wordfence WAF/Cloudflare friction) without any visible UX change.

= 1.1.17 =
* Fix: bulk no longer stops after 3-5 items on shared hosts. The previous worker iterated all items inside a single PHP process, which got killed by `max_execution_time` (typically 30-60 s on shared hosts) mid-loop — leaving the current item stuck in `processing` and the queue frozen. Each call now processes EXACTLY ONE item then re-spawns itself via WP-Cron + `spawn_cron()` for the next. Workers stay well under any `max_execution_time` value.
* Fix: running multiple individual optimizations in parallel no longer saturates PHP-FPM. The status endpoint is now the worker for single-item flows too — instead of one long-running FPM process per task, every poll handles at most one ~25 s slice. With 4 FPM workers the host can handle 4 simultaneous optimizations cleanly instead of choking after 3-5.
* Fix: try/catch around every Flask call. If the AI client throws (network, timeout, OpenAI 5xx), the item is recorded as `failed` with the exception message and the queue continues. Previously, an exception would kill the worker mid-state-update, leaving items stuck in `processing` until the 90 s recovery kicked in.
* Improve: explicit memory hygiene between bulk items (`unset` of the AI response payload + `gc_collect_cycles()`). On hosts with low `memory_limit`, this keeps long bulks well below the cap.
* Improve: single-item status fallback now triggers after 3 s of `pending` (instead of 30 s) so a non-FPM host where neither cron nor `fastcgi_finish_request` fires sees processing start within the first poll cycle.
* Improve: 90 s stuck-item recovery now also applies to single-item tasks, not just bulk.

= 1.1.16 =
* Fix: stuck-item recovery in bulk worker. If a worker crashes mid-item (FPM killed, OOM, container restart), the item is no longer abandoned in `processing`. After 90 s without a heartbeat, the next worker pass picks it up.
* Fix: orphan UI rows on bulk cancel/error. Rows still showing the spinner ("In progress…") at the moment the user cancels or the network drops are now reset cleanly.
* Fix: distinct "Cancelled" summary in the bulk progress bar instead of the misleading "Bulk complete!" toast.
* Fix: bulk no longer flashes "Queued" on already-optimized rows when the user includes them in a re-run.
* Fix: defensive `removeClass` on row badges so visual state can't accumulate stale classes when cycling done → re-run → failed.
* Fix: missing localized strings (`generate`, `cancelled_summary`) — buttons now stay in the user's language after a generation completes.

= 1.1.15 =
* New: bulk product and bulk category optimization are now fully asynchronous (start → poll → complete) with per-item state tracking. The previous design held the browser open for one HTTP request per item, which timed out on Cloudflare and overwrote any concurrent run. Now a single background worker processes the queue while the browser polls a status endpoint every 3 s.
* New: per-row UI updates during bulk. Each product/category row shows its real-time state — `Queued` → `In progress…` (with a spinner) → `Optimized` (with new SEO score) — exactly like single-item optimization. The "Optimize" button on each row is automatically disabled while processing.
* New: progress percentage everywhere. Article generation, single product/category optimize, and bulk all show a percentage bar with elapsed time and estimated phase ("AI is writing your content…", "Finalizing…"). Single-item progress uses an asymptotic estimator based on a per-task ETA that never reaches 100% before the worker actually returns.
* New: `Cancel` button on bulk operations. The worker checks the cancellation flag between items so cancelling a 50-item bulk halts after the current item finishes (within ~30 s) instead of running to completion in the background.
* New: bulk resumes automatically. Closing the admin tab during a bulk no longer abandons the job — when the page reloads, the JS detects the active task and reattaches its UI to the still-running worker.
* New: bulk singleton lock. Starting a bulk while one is already active no longer overwrites the queue; it reattaches to the running task instead.
* Improve: per-item error capture. Failures during bulk are stored on each item's status so the UI can show which products/categories failed and why (tooltip on the `Failed` badge).

= 1.1.14 =
* Fix: admin assets (admin.js, admin.css) now use a `filemtime()`-based cache buster on top of the plugin version. Hard-refreshes the browser/CDN cache the moment the JS file changes, even when an update was pushed without bumping the user-visible version. Fixes "user is on the new plugin but the browser still calls the old AJAX endpoints".
* Improve: legacy synchronous endpoints (`essiow_optimize_product`, `essiow_optimize_category`, bulk processors) now also call `session_write_close()` and raise the PHP time limit before doing any work. Mitigates 504 timeouts on shared hosts where Wordfence WAF or similar serializes admin-ajax requests through a session lock.

= 1.1.13 =
* Fix: product and category optimization are now also async (same `start → poll → result` pattern as blog articles), so single-product and single-category optimizations no longer fail with a 504 Gateway Timeout on hosts behind Cloudflare. The legacy synchronous `essiow_optimize_product` / `essiow_optimize_category` endpoints are kept for backward compatibility (used by the bulk optimizer that already handles its own retries).
* Improve: shared `runEssiowAsyncTask()` helper in admin.js — same network resilience for products/categories as for articles (30 s XHR timeout, 5 consecutive 504s tolerated, 8 s polling interval).
* Improve: prompts now ban colons in titles outright (no exceptions). The previous "avoid colons unless splitting two clearly different ideas" wording was misinterpreted by the AI as permission to keep generic " : guide / efficace / pas cher" suffixes. Article, product and category SEO titles now use dashes, commas, "vs" or rephrasing instead.

= 1.1.12 =
* Fix: definitive fix for "Erreur réseau / 504" on sites behind Cloudflare with Wordfence WAF or any plugin that opens a PHP session. Every AJAX handler now calls `session_write_close()` at the very top, so concurrent polls are never blocked behind a worker that holds the session lock.
* Fix: removed the HTTP loopback dispatch — on Cloudflare-fronted sites the loopback request to admin-ajax.php went through Cloudflare too and counted as another concurrent admin-ajax hit, which triggered WAF serialization and saturated FPM workers. The plugin now relies on (1) `fastcgi_finish_request()` when available + (2) WP-Cron with `spawn_cron()` triggered immediately + (3) a poll-driven fallback in `check_status` that runs the task itself if it has been pending more than 30 seconds.
* Improve: client-side polling is now resilient to transient 504/timeout errors. A single failed poll no longer kills the generation: up to 5 consecutive network errors are tolerated, the polling interval is 8 s instead of 3 s, the first poll fires after 10 s, and each XHR has an explicit 30 s timeout (well below Cloudflare's 100 s origin timeout).

= 1.1.11 =
* Fix: blog article generation no longer triggers a 504 Gateway Timeout on hosts behind a strict reverse proxy (Cloudflare, Caddy, hardened NGINX). The previous 1.1.8 dispatch ran `run_task_inline` inside a `shutdown` action, which keeps the FPM connection open until the AI call completes (10–30 s) — proxies that buffer the entire response would time out at 60 s. The new flow sends the JSON response, calls `fastcgi_finish_request()`, THEN processes the task in background. The browser sees a sub-second response.
* Improve: loopback fallback (for hosts without `fastcgi_finish_request`) now uses a 0.5 s timeout instead of 1 s — fewer cases of the parent request hanging while it waits for the loopback to dispatch.

= 1.1.10 =
* Fix: blog article generation now passes the real WooCommerce category permalinks to the AI (the previous payload key `cat_links` was ignored by the server, which expects `category_links`). Articles now contain real internal links to your store categories instead of invented or missing ones.
* Fix: category optimization now passes blog post permalinks under the correct `blog_posts` key — the AI can finally weave links to your real articles into the long category description.
* Add: JSON-LD `BlogPosting` schema is now emitted on the front-end of every Essiow-generated article (gated by the existing schema option). Includes headline, description, datePublished, dateModified, author, publisher, image, keywords. Helps rich snippet eligibility for users not running Yoast/Rank Math.

= 1.1.9 =
* Improve: blog articles, products and categories are now generated with intent-driven titles. The AI must analyze the search intent (informational, commercial, transactional, navigational) and produce a question-style or affirmative title that directly answers it — replaces generic clichés like "X : guide complet et conseils efficaces".
* Improve: AI no longer paraphrases the prompt. Forbidden patterns explicitly listed in prompts: "Introduction" / "Présentation" / "Pour commencer" headings, "voici les liens", "Dans cet article", "Saviez-vous que…", "De nos jours…". Articles must open with the actual answer in the first sentence.
* Fix: published articles now appear as proper Gutenberg blocks (paragraph, heading, list, table, image, quote, separator) instead of a single HTML block. The plugin parses the AI HTML with DOMDocument and wraps each top-level element in the correct `<!-- wp:... -->` annotation before `wp_insert_post`.
* Fix: residual "Introduction" / "Présentation" H2 headings the AI may still slip in are now stripped before publishing.

= 1.1.8 =
* Fix: blog article generation no longer hangs with `admin-ajax.php` ERR_TIMED_OUT on shared / mod_security hosts. Background dispatch now uses a 3-tier strategy: fastcgi_finish_request() (instant, PHP-FPM hosts), HTTP loopback (existing), and WP-Cron fallback (always works). The first available wins; redundant workers are idempotent (transient state guards against double-processing).
* Improve: client-side polling extended from 5 min to 10 min so 5000-word articles have time to complete on slower OpenAI responses.
* Improve: HTTP loopback now forwards cookies for hosts that require an authenticated session even on nopriv handlers.

= 1.1.7 =
* Fix: API key now persists correctly across saves (no longer "disappears" after Test Connection)
* Fix: rare "Invalid API key" error caused by encryption format collision (random IV containing the legacy "::" separator) — new "v2:" format is collision-proof, legacy "v1" payloads remain readable
* Add: static cache on get_api_key() prevents redundant decryptions and migration race conditions within a single request
* Add: 5-minute transient cache on license verification, 60-second transient on credit balance — fewer redundant API calls per admin page load
* Add: automatic retry with backoff (1s, 3s) on network errors and 5xx responses (4xx auth/validation are not retried)
* Add: auto-purge of essiow_last_errors entries older than 7 days
* Settings UI: API key field now shows the masked saved key as placeholder, leave empty to keep the saved key
* Improve: uninstall.php now lists encrypted-key options explicitly

= 1.1.6 =
* Fix: blog article generation now uses asynchronous task processing to avoid "Network error" on hosts with short proxy or PHP-FPM timeouts
* Improve: background generation worker keeps running on long AI calls (ignore_user_abort, extended time limit, session lock released)

= 1.0.0 =
* Initial release
* Product SEO optimization with descriptions, meta, alt text, schema
* Category SEO optimization with rich content and FAQ
* Blog article generator with product integration
* AI Sales Agent with chatbot widget
* 8 languages, 4 tones, 3 content lengths
* Bulk optimization with progress tracking
* Yoast SEO, Rank Math, All in One SEO support
* GDPR compliant

== Upgrade Notice ==

= 1.1.29 =
Massive SEO release : AI re-optimize uses your real Search Console queries (top 10 / striking distance), new Opportunities tab (cannibalization, low CTR, lost rankings), Issues report, Audit tab (image SEO + schemas), auto BreadcrumbList + FAQPage JSON-LD. Required.

= 1.1.28 =
Adds Pause / Resume / Cancel controls during bulk optimization. Leaving the page now cancels the bulk automatically (saved items stay, pending queue is dropped). Auto-resume on page load removed by design.

= 1.1.27 =
Fixes Search Console KPIs stuck at 0 when the WP server returns 503 on admin-ajax (Wordfence/Cloudflare overload). JS now retries with exponential backoff. Recommended.

= 1.1.26 =
Auto-syncs Search Console data on page load (no more empty Overview after connecting), populates the Performance tab with striking-distance keywords, and auto-picks the property variant with the most actual data.

= 1.1.25 =
Cosmetic fix: replaces the misleading "Traitement en cours…" placeholder with a clearer empty state on the Search Console Indexation overview.

= 1.1.24 =
Removes the manual "Change property" UI now that auto-fallback handles property variants automatically.

= 1.1.23 =
Search Console connection is now self-healing: tries every property variant (sc-domain, www, http) until one works, and surfaces Google's real error message when none does. Recommended.

= 1.1.22 =
Fixes Search Console 404 sync errors when your GSC property URL doesn't exactly match the WP site URL (sc-domain, www, http variants). Adds a manual "Change property" picker. Recommended.

= 1.1.21 =
Critical fixes for 1.1.20 Search Console: OAuth response format, missing cryptography dependency, empty Indexation tab, indexation column on categories, `is_connected` guards, missing strings. Required if you upgraded to 1.1.20.

= 1.1.20 =
Major release: full Google Search Console + IndexNow integration. New "Search Console" admin menu with stats, indexation status, sitemap submission, auto IndexNow on publish, and a per-product "Indexation" column. Recommended.

= 1.1.19 =
Removes the page reload after a single category optimize (so concurrent optimizations don't get killed) and silences the spurious "Task not found" toast on page reload. Recommended.

= 1.1.18 =
Fixes three concurrency bugs in 1.1.17 bulk: filtered re-selection re-running everything, items getting stuck in queue from parallel poll-driven processing, and spurious "Task not found" errors during transient races. Recommended.

= 1.1.17 =
Critical fix for bulk and parallel optimizations stopping after 3-5 items. Each Flask call is now isolated to its own short-lived PHP process so `max_execution_time` and FPM worker saturation can't interrupt the queue. Recommended.

= 1.1.16 =
Polish on 1.1.15 bulk: stuck-item recovery, clean cancel/error UX, missing strings. Recommended.

= 1.1.15 =
Major bulk overhaul: full async dispatch (no more 504 on category bulk), per-row progress states like single optimize, percentage bar everywhere, cancel button, auto-resume on page reload. Recommended for anyone using bulk optimization.

= 1.1.14 =
Adds a filemtime-based cache buster so the new admin JS is loaded immediately after update, plus session/timeout hardening on legacy sync endpoints. Recommended for anyone still seeing 504 on category optimize after 1.1.13.

= 1.1.13 =
Fixes 504 Gateway Timeout on single-product and single-category optimization (same async dispatch as blog), and bans colons in AI-generated titles. Recommended update.

= 1.1.12 =
Definitive fix for "Erreur réseau / 504" on sites behind Cloudflare + Wordfence (or similar). Concurrent polls no longer block on PHP sessions, the loopback dispatch is removed, and the JS tolerates transient network errors. Recommended update for everyone on 1.1.8 → 1.1.11.

= 1.1.11 =
Critical fix for "Erreur réseau / 504" when generating blog articles on hosts behind Cloudflare/Caddy/strict NGINX. The browser response now closes before the AI call runs. Recommended update.

= 1.1.10 =
Fixes a payload mismatch that prevented categories and blog links from reaching the AI for articles and category pages, and adds JSON-LD Article schema. Recommended update for anyone on 1.1.8 or 1.1.9.

= 1.1.9 =
Major content quality fix: AI now writes intent-driven titles (no more "guide complet" clichés), stops paraphrasing the brief ("Introduction", "voici les liens"), and articles publish as real Gutenberg blocks instead of a single HTML block. Recommended update.

= 1.1.6 =
Fixes a "Network error" that could appear when generating blog articles on hosts with short HTTP proxy timeouts. Recommended update.

= 1.0.0 =
Initial release of Essiow AI SEO Suite for WooCommerce.
