=== OptiPic Image Optimizer ===
Contributors: optipic
Tags: image optimization, compress images, webp, avif, performance
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatically compress and convert your Media Library images to WebP/AVIF using the OptiPic cloud service — no server-side image libraries required.

== Description ==

OptiPic Image Optimizer offloads image compression to the OptiPic cloud service, so your server never has to run its own compression tools. Just connect your OptiPic account and the plugin takes care of the rest.

**Key features**

* **Automatic optimization on upload.** New Media Library uploads are queued for optimization in the background — your upload screen never waits on OptiPic.
* **Bulk-optimize your existing library.** One click queues every unoptimized image; you can safely close the tab and it keeps going.
* **Modern formats.** Serve WebP automatically, with no format picker to think about.
* **One simple compression choice.** Balanced or Maximum — no confusing quality sliders, though a numeric override is available for power users under Advanced.
* **Optional thumbnail-size optimization.** Generate WordPress's thumbnail sizes straight from the original for the best quality, or just compress the sizes WordPress already made.
* **Automatic backups.** Keep a copy of every original file and restore it with one click, any time.
* **OptiPic History screen.** A full before/after report of everything this site has ever sent to OptiPic, with a Compare view and one-click restore.
* **Exclusions.** Skip specific files (e.g. your logo) by filename pattern.
* **Lightweight background processing.** No external job-queue library — a small built-in runner keeps work moving via a real WP-Cron event, plus an admin-page and AJAX-driven tick while you have an OptiPic screen open.
* **Translated error messages.** If an image fails to optimize, you get a plain-English reason and next step — never a raw error code.
* Fully translatable; a Persian (fa_IR) translation is included.

= How it works =

1. Create an account at OptiPic and grab your API token from the dashboard's **API & Usage** tab.
2. Enter your account email and token under **Settings → OptiPic**.
3. New uploads are optimized automatically from then on. Use **Media → Bulk Optimize** to process everything already in your library.

= Requirements =

* An OptiPic account with a valid API token.
* Outbound HTTPS access from your server to the OptiPic API (most hosts allow this by default).

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/optipic-image-optimizer` directory, or install the zip directly through the Plugins screen in WordPress.
2. Activate the plugin through the **Plugins** screen.
3. Go to **Settings → OptiPic** and enter your account email and API token.
4. Optionally visit **Media → Bulk Optimize** to process your existing library.

== Frequently Asked Questions ==

= Do I need an OptiPic account? =

Yes. Compression happens on OptiPic's servers, not on your host — you need an account and an API token from your OptiPic dashboard.

= Will removing the plugin delete my optimized images? =

No. Uninstalling the plugin removes only its own settings and internal tracking data. Your media files — optimized or not — and any saved backups are never touched.

= What happens if optimization fails for an image? =

The Media Library's OptiPic column shows a plain-English reason (hover for detail). Only transient/unexpected failures are retried automatically; failures like an invalid API token or an exceeded budget are not retried endlessly, since retrying those can never succeed on its own.

= Can I restore the original file after it's optimized? =

Yes, as long as "Keep a copy of the original file" was enabled at optimization time. Use the "Restore original" link in the Media Library's OptiPic column, or from the OptiPic History screen.

= Does this support WebP or AVIF? =

The plugin currently converts to WebP automatically when "Serve modern formats automatically" is enabled. AVIF delivery requires per-visitor content negotiation and isn't offered yet.

= Does bulk optimizing require me to keep the browser tab open? =

No. Clicking "Optimize library" queues the work and returns control to you immediately; processing continues via a scheduled WP-Cron event and on your next admin page load regardless of whether the tab stays open. Keeping the tab open makes it finish faster (it also polls in the background), but isn't required.

== Screenshots ==

1. Settings screen — connect your account and choose your defaults.
2. Media Library with the OptiPic status column.
3. Bulk Optimize progress screen.
4. OptiPic History — before/after report with Compare.

== Changelog ==

= 0.1.0 =
* Initial release: auto-optimize on upload, Bulk Optimize screen, OptiPic History screen, single-page settings, restore-original/backup, optional thumbnail-size optimization, Persian translation.

== Upgrade Notice ==

= 0.1.0 =
Initial release.
