=== EcoPigs Auto-Fix ===
Contributors: ecopigs
Tags: carbon, sustainability, performance, images, webp, optimization
Requires at least: 5.5
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 0.1.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Premium add-on for EcoPigs Carbon Badge. Automatically applies the optimisations EcoPigs finds on your site, then rescans to prove your carbon grade improved.

== Description ==

The free EcoPigs Carbon Badge plugin SHOWS you what to improve. EcoPigs Auto-Fix DOES it — starting with the highest-impact, lowest-risk wins: images.

Because it reads the exact same scan data the EcoPigs dashboard shows (the per-asset list of what's oversized or in the wrong format), every fix targets precisely the assets the audit flagged — not a blind sweep of your whole library.

* **Resize oversized images** — regenerate correctly-sized thumbnails so visitors download images scaled to how they're displayed.
* **Convert images to WebP** — generate WebP copies served automatically, with the original kept as a fallback.
* **Lazy-load images & SVGs** — add loading="lazy" where your theme or page builder left it off.

Every fix is **previewable** before you apply it and **revertible** afterwards — originals are never overwritten. After applying, one click triggers a rescan so you can watch your grade move (e.g. B → A).

CSS and JavaScript fixes are coming in a later release behind an opt-in "safe mode" with per-fix toggles.

== Installation ==

1. Install and connect the free **EcoPigs Carbon Badge** plugin first (it supplies your site's scan data and links your EcoPigs account).
2. Install EcoPigs Auto-Fix. There's no licence key — applying fixes unlocks automatically with your EcoPigs plan.
3. Go to Settings → EcoPigs Auto-Fix, choose which fixes to run, Preview, then Apply.

== Changelog ==

= 0.1.4 =
* WebP delivery now rewrites the WHOLE page, so existing .webp copies are served for theme and page-builder images (e.g. Elementor backgrounds, srcset, lazy-loaded images) — not just post content. Only swaps a URL when the .webp file actually exists, and only for browsers that accept WebP.

= 0.1.3 =
* Fixed: Auto-Fix now always targets THIS WordPress site (home URL), never the badge's configurable display URL — so it can no longer fetch another site's optimisations or rescan the wrong domain.
* The rescan button now names the exact site it will scan and asks you to confirm first; the server also refuses any rescan whose domain doesn't match this site.

= 0.1.2 =
* Results now distinguish "already optimised" (e.g. WebP already generated by your cache plugin) from genuine failures — these show as a neutral dash, not a red cross. Added a per-fix summary (done · already optimised · failed) and an honest "…and N more" when the list is long.

= 0.1.1 =
* Images are now matched by file path under /wp-content/uploads/ instead of WordPress' URL-to-attachment lookup, which missed resized and -scaled variants and any www/https difference — fixes "Not a local attachment" on images that are clearly present.
* WebP conversion no longer requires a Media Library match; it works directly on the flagged files.
* Added a progress indicator when running Preview / Apply / Rescan so it's clear something is happening.

= 0.1.0 =
* Initial scaffold: licence gate, image resize / WebP / lazy-load fixers, preview + apply + revert, and the rescan "prove it" loop.
