=== Niquelao Image Optimizer ===
Contributors: kokeperez, kokenet
Tags: image optimization, compress images, webp, imagick, performance
Requires at least: 5.8
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.5.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Automatic PNG, JPEG and WebP image optimizer. No external binaries or API keys required. Works on any shared hosting.

== Description ==

Niquelao Image Optimizer automatically compresses images on upload and allows bulk re-optimization of your entire existing media library. It uses Imagick (preferred) or GD (fallback) — no external dependencies or API keys needed.

**Features:**

* Automatic optimization on every upload
* Bulk optimization of the existing media library
* Optional WebP conversion for every image
* Optional automatic .webp serving via .htaccess under the same original URL (no redirects)
* WordPress thumbnail optimization
* Automatic backup of the original file before processing
* Optional thumbnail backups (disabled by default) plus a Maintenance screen to scan, download and purge accumulated backups
* Detailed savings statistics per file type
* Copyright/authorship EXIF metadata preserved after stripping
* Optional automatic resizing with configurable maximum width and height
* Compatible with Imagick (preferred) and GD (fallback)
* No external dependencies — works on any shared hosting

== Requirements ==

* WordPress 5.8 or higher
* PHP 7.4 or higher
* Imagick or GD extension enabled on the server

== Installation ==

1. Upload the `niquelao-image-optimizer/` folder to `/wp-content/plugins/`
2. Activate the plugin from **Plugins → Installed Plugins**
3. Configure it under **Niquelao Optimizer → Settings**

== Frequently Asked Questions ==

= Does it work on shared hosting? =

Yes. It uses the PHP Imagick or GD libraries, available on virtually all shared hosting providers.

= Are the original images saved? =

Optionally. Enable "Save backup" in the settings to keep a `.niquelao-bak` copy alongside each processed file.

= My hosting has limited disk space / inodes, how do I clean up backups? =

By default only the full-size original is backed up, not every thumbnail size. Go to **Niquelao Optimizer → Maintenance** to scan for accumulated `.niquelao-bak` files, download a ZIP copy, and purge them in batches.

= Is copyright information preserved? =

Yes. The EXIF/IPTC Copyright, Artist and Author fields are preserved after stripping the rest of the metadata.

== Screenshots ==

1. Settings — image resizing, compression quality (JPEG/PNG/WebP) and processing options
2. Bulk Optimization — reoptimize your entire existing media library with a progress bar
3. Savings Statistics — totals by file type and a log of the most recent optimizations
4. Diagnostics — Imagick/GD availability, WebP support and uploads folder permissions
5. Settings — backup options and the new automatic WebP serving via `.htaccess` (no redirects)
6. Maintenance — scan, download and purge accumulated `.niquelao-bak` backup files in batches

== Changelog ==

= 1.5.1 =
* Fixed: Plugin Check findings — replaced direct `unlink()` calls with `wp_delete_file()` in the Maintenance ZIP download and cleanup routines
* Fixed: added justified `phpcs:ignore` annotations for the unavoidable direct `is_writable()`/`readfile()` filesystem calls used to manage `.htaccess` and stream the temporary backup ZIP (no WP_Filesystem equivalent exists for these specific operations)
* Fixed: added justified `phpcs:ignore` annotations for `$_POST['offset']`/`$_POST['token']` reads in Maintenance AJAX handlers, where the nonce is already verified via `check_ajax_referer()` inside `check_permissions()` earlier in the same method
* Fixed: removed the remote Google Fonts `@import` in the admin stylesheet (present since the first approved version) — admin UI now uses a local system-font stack, with no third-party assets loaded
* Fixed: missing i18n wrapper on the "No Imagick/GD detected" troubleshooting copy in the Diagnostics page
* Fixed: hardcoded Spanish strings in the Media Library inline JS (single-image optimize button) now routed through PHP `__()` and passed to the script as a translatable object
* Changed: README.md rewritten to match the current version and defer to readme.txt as the single source of truth for the changelog, instead of duplicating (and drifting out of sync with) it

= 1.5.0 =
* Added: optional setting "Servir WebP automáticamente" — inserts/removes a `.htaccess` block (via WordPress' insert_with_markers()/extract_from_markers()) that serves the `.webp` version under the same original URL when the browser supports it, with no redirects and no URL changes
* Added: status indicators for mod_rewrite availability, `.htaccess` writability and whether the rule block is actually installed
* Added: the `.htaccess` block is automatically removed on plugin deactivation and uninstall, leaving no leftover server rules

= 1.4.0 =
* Added: optional "Keep thumbnail backups" setting (off by default) — when disabled, only the full-size original gets a `.niquelao-bak` copy instead of every generated thumbnail size, saving disk space and inodes
* Added: new Maintenance screen to scan, download (as ZIP) and bulk-purge accumulated `.niquelao-bak` files, processed in batches via AJAX to support shared hosting with execution time/inode limits
* Added: uninstall routine now also removes the temporary ZIP folder and the new backup-thumbs option

= 1.3.5 =
* Fixed: settings page hook suffixes were calculated manually and didn't match the real hook suffixes generated by WordPress (which derive from the top-level menu_title, not the menu slug), causing CSS/JS to fail to load on Bulk Optimization, Statistics and Diagnostics pages
* Fixed: admin styles/scripts now use the real hook_suffix returned by add_menu_page()/add_submenu_page() instead of a hardcoded guess
* Fixed: media library "Optimize" button (upload.php/post.php) registered its own style/script handle instead of relying on a handle that wasn't enqueued on those screens
* Fixed: synced plugin version number across the main file header, the NIQUELAO_VERSION constant and readme.txt Stable tag
* Fixed: missing i18n wrapper on one bulk-optimization status string

= 1.3.2 =
* Unified license to GPL-2.0-or-later across all files
* Added full internationalization (i18n) via __() and esc_html__() functions
* Updated Text Domain header to match plugin slug (niquelao-image-optimizer)
* Removed deprecated load_plugin_textdomain() call (auto-loaded since WP 4.6)
* Created uninstall.php to clean up table, options and postmeta on uninstall
* Fixed require_once order: all includes at the top of the main file
* languages/ folder ready for translations

= 1.3.1 =
* Updated Plugin URI to kokeperez.es

= 1.3.0 =
* Added automatic resizing with configurable maximum width and height
* EXIF Copyright/Artist metadata now preserved after stripping (Imagick and GD)

= 1.2.0 =
* Atomic file writes using a temporary file
* Improved diagnostics page

= 1.1.0 =
* Bulk optimization with progress bar
* WebP conversion support
* Statistics page

= 1.0.0 =
* Initial release
