=== MediaVoom - Image Optimizer & Media Cleaner ===
Contributors: yuss246
Tags: image optimization, media cleaner, webp, unused images, duplicate images
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.6
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Safely audit and clean your Media Library, detect duplicates and orphan files, and generate local WebP/AVIF images without sending media to an external service.

== Description ==

MediaVoom is a safety-first Media Library maintenance toolkit that combines usage auditing, reversible cleanup, exact duplicate detection, orphan-file discovery, and local next-generation image generation in one workflow.

Its cleanup tools are deliberately conservative: files are classified before action, cleanup candidates can be moved to reversible Safe Trash, and permanent deletion remains a separate administrator-controlled step.

= Image optimization =

* Generate WebP copies locally.
* Generate AVIF copies when the server can reliably encode AVIF.
* Process original images and WordPress-generated image sizes.
* Optional optimization of new uploads.
* Frontend next-generation delivery using standards-based `<picture>` markup.
* Original JPEG/PNG/WebP files remain available as the fallback.
* Background bulk processing with Pause, Stop, Continue, Restart, WP-Cron fallback, and stale-job recovery.
* Existing up-to-date generated files are reused instead of regenerated.

= Media cleanup =

* Scan WordPress for media usage across content, featured images, common metadata, taxonomy metadata, widgets, theme settings, WooCommerce, Elementor, and selected media-shaped settings.
* Classify attachments as Used, Probably Unused, Needs Review, or Missing File.
* Move selected cleanup candidates to reversible Safe Trash.
* Restore Safe Trash items before permanent deletion if you change your mind.
* Detect exact duplicate images using SHA-256 file hashes.
* Scan the uploads filesystem separately for orphan files.
* Filter and bulk-select cleanup candidates.
* Keep technical optimizer messages on a separate Logs screen.

= Safety and privacy =

MediaVoom does not automatically delete media.

"Probably Unused" means that no supported reference was detected. A theme or plugin can still store a media reference in a custom location, so review cleanup candidates before moving or deleting them.

Image optimization is performed locally on your WordPress server. MediaVoom does not require an external optimization API and does not include telemetry.

= Multisite =

MediaVoom is multisite-aware. Each site keeps its own scan state, settings, Safe Trash, optimizer jobs, duplicate results, and orphan results. Network activation initializes defaults for existing sites and for newly created sites.

== Installation ==

1. Upload the `mediavoom-image-optimizer` folder to `/wp-content/plugins/`, or upload the ZIP from Plugins > Add New.
2. Activate **MediaVoom - Image Optimizer & Media Cleaner**.
3. Open **MediaVoom** in WordPress Admin.
4. Run the Media Usage Scanner before performing cleanup.

== Frequently Asked Questions ==

= Does MediaVoom delete images automatically? =

No. Cleanup actions require an administrator to explicitly select the files. Safe Trash is reversible and permanent deletion is a separate action.

= Are "Probably Unused" files guaranteed to be unused? =

No. It means MediaVoom did not find a supported WordPress reference. Custom theme or plugin code can store media references in other locations.

= Are original images replaced during optimization? =

No. MediaVoom generates next-generation copies and keeps the original file untouched.

= Does frontend delivery require server rewrite rules? =

No. MediaVoom can output `<picture>` / `<source>` markup when matching generated files exist. The original image remains as the fallback.

= Does MediaVoom work with WooCommerce? =

The scanner checks common WooCommerce image fields and product galleries, and frontend delivery hooks into WooCommerce product image HTML.

= Does it use a third-party image optimization service? =

No. Conversion is performed locally using the image capabilities available on the WordPress server.

= What happens to Safe Trash if I uninstall MediaVoom? =

MediaVoom attempts to restore quarantined media before removing plugin state. If a restore cannot be completed, the Safe Trash index is preserved rather than discarding the recovery map.

= Are generated WebP/AVIF files deleted on uninstall? =

No. Generated image files are preserved intentionally to avoid breaking cached or externally stored markup.

= Does it support multisite? =

Yes. MediaVoom stores and processes data per site. Network activation initializes the plugin for current sites and newly created sites.

== Screenshots ==

1. MediaVoom dashboard with media health metrics and the Safe Media Usage Scanner.
2. Bulk image optimizer with WebP/AVIF generation and background processing.
3. Safe Trash workflow for reversible media cleanup.
4. Duplicate and orphan-media management tools.

== Source Code ==

All first-party JavaScript and CSS included with MediaVoom is shipped directly in human-readable, modifiable source form. No minified or obfuscated first-party JavaScript is distributed, and no build step is required to modify the bundled admin assets.

MediaVoom does not bundle third-party JavaScript or CSS libraries.

== External Services ==

MediaVoom performs image optimization locally on the WordPress server. It does not require an external optimization API, does not send media to a third-party optimization service, and does not include telemetry.

== Upgrade Notice ==

= 1.0.6 =

Directory review compatibility update: removed the unresolved optional Author URI.

== Changelog ==

= 1.0.5 =
* Standardized the plugin name and all first-party runtime identifiers on the MediaVoom namespace.
* Updated publisher branding to TheLeoPress.
* Removed CSS that suppressed unrelated WordPress and third-party admin notices.
* Repositioned the plugin around safety-first Media Library auditing, reversible cleanup, duplicate/orphan detection, and local WebP/AVIF generation.
* No external optimization API or telemetry is used.

= 1.0.4 =
* Standardized runtime, option, hook, AJAX, nonce, meta, transient, script and CSS identifiers on the distinctive MediaVoom prefix to reduce collision risk.
* Renamed internal class files and PHP classes to use the MediaVoom prefix.
* Removed suppression of unrelated WordPress admin notices on MediaVoom screens.
* Added explicit human-readable source-code and external-service disclosures for WordPress.org review.
* Kept all image optimization local to the WordPress server; no telemetry or external optimization API is used.
* No original media files are automatically deleted.

= 1.0.3 =
* Existing plugin data and media are unchanged.


= 1.0.2 =
* Added MediaVoom branding/logo to the plugin navigation bar.
* Added bundled admin logo assets.
* Added complete WordPress.org icon, banner and screenshot asset pack.
* No scanner, optimizer, Safe Trash, duplicate, orphan or generated-media data is changed by this update.


= 1.0.1 =
* Removed obsolete development-version roadmap cards and old audit-only version wording from the dashboard.
* Added search, status, and size filters to the latest attention results.
* Added Select All Visible Eligible and bulk Move to Safe Trash actions directly on the dashboard results.
* Added a per-image Move to Safe Trash action for eligible Probably Unused attachments.
* Missing-file and Needs Review rows remain non-destructive from the dashboard.
* Fixed Plugin Check global-variable prefix warnings in uninstall.php.
* Existing scanner data, optimizer jobs, generated images, Safe Trash, duplicates, orphans, and logs are preserved.


= 1.0.0 =
* First stable public release.
* Added versioned data migration so existing installations inherit new defaults safely without losing scanner or optimizer state.
* Added multisite-aware activation, deactivation, and new-site initialization.
* Added deactivation cleanup for background schedules and watchdog locks while preserving resumable job data.
* Hardened frontend WebP/AVIF delivery for image URLs containing query strings or fragments.
* Prevented frontend delivery markup from being injected into normal wp-admin screens or feeds.
* Added safe multisite uninstall cleanup.
* Safe Trash items are restored before uninstall state is removed; failed restores keep their recovery index.
* Generated WebP/AVIF files are preserved during uninstall to prevent broken cached references.
* Finalized WordPress.org metadata, FAQ, privacy/safety language, installation instructions, and stable version information.

= 0.8.1 =
* Fixed the MediaVoom admin UI losing its CSS and JavaScript after the rebrand.
* Admin assets now load by plugin page slug instead of generated WordPress hook names.
* Fixed the two Plugin Check warnings reported in v0.8.0.
* Removed the direct https_local_ssl_verify hook invocation from the background loopback request.
* Renamed the scanner extension hook to mediavoom_image_optimizer_scanner_meta_keys.
* Existing plugin data and generated media are preserved.


= 0.8.0 =
* Rebranded the release candidate as MediaVoom - Image Optimizer & Media Cleaner.
* Changed the proposed public plugin folder, main file, and text domain to mediavoom-image-optimizer.
* Updated WordPress.org-facing description and discovery tags.
* Updated admin branding to MediaVoom.
* Preserved existing scan data, optimizer jobs, Safe Trash records, duplicate/orphan results, and logs during the rebrand.
* Includes the v0.7.2 scanner compatibility fix and v0.7.1 background optimizer reliability improvements.


= 0.7.2 =
* Fixed the Media Usage Scanner error "Unknown column option_id in WHERE".
* The targeted WordPress options scan no longer depends on an option_id column.
* Options are now paginated deterministically by option_name with a saved stage offset.
* Existing scan results, optimizer progress, generated images, Safe Trash data, duplicates, orphans, and logs are preserved.
* Includes the v0.7.1 background optimizer reliability fixes.

= 0.7.1 =
* Fixed bulk optimization stalling after leaving the Optimizer screen on some shared hosts.
* Improved non-blocking loopback handoff reliability for the background optimizer.
* Schedules the WP-Cron fallback before each work cycle so interrupted requests can recover.
* Added a lightweight watchdog that restarts stale running jobs when normal WordPress traffic occurs.
* Added a short watchdog lock to avoid overlapping recovery workers.
* Reduced fallback delay while preserving saved progress and completed-attachment tracking.
* Existing optimization progress and generated files are preserved.

= 0.7.0 =
* Added frontend WebP/AVIF delivery using standards-based picture/source markup.
* Keeps original JPEG/PNG images as the browser fallback.
* Supports WordPress attachment images, featured images, post content, and WooCommerce image HTML.
* Generates next-gen srcset values only when every referenced local derivative exists.
* Leaves external and CDN-hosted image URLs untouched.
* Added a Frontend delivery toggle to Optimizer settings.
* No original media files are replaced or deleted.

= 0.6.3 =
* Final Plugin Check warning cleanup based on the v0.6.2 report.
* Added narrowly scoped security annotations at the exact Safe Trash request-read lines after nonce/capability verification.
* Clarified bulk attachment ID normalization after wp_unslash() and absint sanitization.
* Moved the intentional read-only scanner database-query annotation to the exact aggregate query line.
* Existing plugin data and media remain untouched.

= 0.6.2 =
* Follow-up Plugin Check cleanup after v0.6.1 reached zero errors.
* Documented nonce verification at protected AJAX request-read sites.
* Bulk attachment IDs are unslashed and normalized element-by-element before use.
* Added narrow documentation for two intentional read-only scanner aggregate count queries.
* Existing plugin data is preserved.

= 0.6.1 =
* Corrected the Plugin Check findings reported against v0.6.0.
* Replaced direct PHP rename() calls in Safe Trash with WP_Filesystem move operations.
* Added wp_unslash() and normalization for attachment IDs received by admin AJAX actions.
* Corrected SQL LIKE wildcard handling by using esc_like() values through wpdb prepare placeholders.
* Corrected prepared-query execution annotations for dynamically generated IN placeholders.
* Removed the generic dynamic table/count SQL helper and replaced it with explicit core-table scanner count queries.
* Renamed the scanner filter hook to use the full mediavoom_image_optimizer prefix.
* No existing scan, optimizer, Safe Trash, duplicate, orphan, or log data is reset.

= 0.6.0 =
* Added the missing Orphans tab to the main plugin workflow navigation, including Optimizer.
* Security hardening before wider testing.
* Confirmed privileged AJAX actions require manage_options capability and a valid WordPress nonce.
* Safe Trash now rejects traversal, stream-wrapper, and filesystem paths outside the WordPress uploads directory.
* Safe Trash move, restore, and permanent-delete operations validate both source and destination paths.
* Permanent attachment deletion now uses wp_delete_attachment() instead of direct database deletion, allowing WordPress cleanup hooks and cache invalidation to run normally.
* Existing optimizer, scan, Safe Trash, duplicate, orphan, and log data is preserved.

= 0.5.3 =
* Added Clear Logs on the Logs page.
* Added log filtering by date and time range.
* Existing search and format filters remain available.
* Clear Logs removes stored optimizer error history only and does not modify media files.

= 0.5.2 =
* Added clear guidance for choosing which duplicate copy to keep.
* Added duplicate search, file-size filters, and Suggested Keep / Duplicate Copy filtering.
* Added per-duplicate checkboxes and Select All Visible Duplicates.
* Added bulk Move Selected to Safe Trash; selected files remain restorable and are not permanently deleted.
* Suggested Keep rows cannot be bulk-selected by default.
* Removed Logs from the main horizontal workflow navigation while keeping the Logs page available from the WordPress sidebar and Optimizer View Logs action.

= 0.5.1 =
* Fixed fatal error on the Orphans admin page caused by a malformed submenu callback registration.
* Rebuilt all Media Optimizer submenu registrations with explicit valid class callbacks.
* No scanning or optimization data is reset by this update.

= 0.5.0 =
* Split Duplicates and Orphan Files into separate tools.
* Duplicate scanning now checks Media Library attachments only for much faster exact-hash duplicate detection.
* Added a dedicated Orphans page for optional deep uploads-filesystem scanning.
* Added independent background progress, Pause, Stop, Continue, and Restart controls for both Duplicates and Orphans.
* Added a dedicated Logs page for technical optimizer errors.
* Removed raw technical error details from the main Optimizer screen; users now see a friendly message and a View Logs button.
* Updated plugin navigation to Dashboard, Optimizer, Safe Trash, Duplicates, Orphans, and Logs.

= 0.4.2 =
* Replaced raw optimizer server errors with user-friendly warnings.
* Technical image-editor messages are hidden under an expandable View technical details section.
* Repeated AVIF encoder failures automatically stop AVIF for the current run instead of creating hundreds of identical errors.
* WebP optimization continues when AVIF is stopped.
* Original images remain untouched.
* Removed leaked PHP/source text from the Duplicates & Orphans page.

= 0.4.1 =
* Fixed the Safe Trash submenu callback regression in v0.4.0.
* Rebuilt Duplicates & Orphans scanning as a true background job.
* Added live progress for attachment hashing and uploads filesystem scanning.
* Added Pause, Stop, Continue, and Restart From Zero controls.
* Scan progress is preserved after Pause/Stop and continues after leaving the page.
* Added live duplicate-group, extra-copy, and orphan counters during scanning.
* Added WP-Cron fallback and a secure loopback worker so long scans do not depend on one AJAX request.

= 0.4.0 =
* Added Duplicates & Orphans phase.
* Exact duplicate detection uses SHA-256 hashes of original attachment files.
* Duplicate groups show all matching attachments, thumbnails, file sizes, and a conservative suggested copy to keep.
* Added estimated duplicate storage recovery.
* Added conservative uploads-folder orphan detection against known attachment originals, WordPress image sizes, WebP, and AVIF siblings.
* Orphan results include search, type, and size filters.
* Duplicate/orphan phase is audit-only; nothing is deleted automatically.

= 0.3.4 =
* Fixed AVIF jobs that could report Ready but fail during actual conversion.
* AVIF conversion now falls back from the WordPress image editor to explicit Imagick and then GD imageavif() when available.
* Added exact optimizer error logging with attachment ID, filename, format, and server/image-editor message.
* Added a visible optimizer error details panel with separate WebP and AVIF error counts.
* Removed all third-party and WordPress admin notices from every MediaVoom - Image Optimizer & Media Cleaner screen using action suppression plus CSS fallback.

= 0.3.3 =
* Added multi-selection to Probably Unused media and Safe Trash contents.
* Added Select All Visible for filtered Probably Unused results.
* Added bulk Move Selected to Safe Trash.
* Added Select All, Restore Selected, and Permanently Delete Selected in Safe Trash.
* Bulk permanent deletion requires an explicit confirmation.
* Bulk actions preserve existing Safe Trash safety rules.

= 0.3.2 =
* Fixed Optimizer state buttons not changing after Pause or Stop.
* The button-state helper had been scoped inside the scanner script, causing the Optimizer UI update to stop with a JavaScript error.
* Running now shows only Pause and Stop.
* Paused or stopped now shows only Continue and Restart From Zero.
* Completed shows Run Again and Restart From Zero.
* Button state changes happen immediately without a page refresh.

= 0.3.1 =
* Fixed AVIF support incorrectly changing to Unavailable after AVIF files had already been generated.
* Successful WebP/AVIF generation is now persisted as verified server capability.
* Optimizer now shows only context-relevant controls: running shows Pause/Stop; paused or stopped shows Continue/Restart; completed shows Run Again/Restart.
* Restored distraction-free plugin pages by hiding unrelated WordPress and third-party admin notices on all plugin screens.
* Added Safe Trash filters for search, image type, and file size.
* Added media thumbnails plus View Media and Media Details actions before moving an item to Safe Trash.

= 0.3.0 =
* Added reversible Safe Trash for scanner-flagged Probably Unused media.
* Safe Trash moves originals, WordPress thumbnails, and generated WebP/AVIF siblings together.
* Added Restore and separately confirmed Permanent Delete actions.
* Nothing is automatically deleted.
* Optimizer buttons now change immediately to match Start, Pause, Continue, Stop, and completed states.

= 0.2.5 =
* Fixed Continue after Pause/Stop so the job processes immediately and resumes reliably.
* Added a browser heartbeat that re-kicks a running background job if the worker chain stalls.
* Fixed WebP/AVIF generated counters to count only newly created files, not reused files.
* Fixed AVIF handling so successful AVIF generation is preserved while failed conversions report real errors.
* Real WebP/AVIF capability checks now use an actual local conversion test.
* Fixed the AVIF-only retry job and preserved all existing optimized files.

= 0.2.4 =
* Fixed AVIF capability reporting by performing a real local conversion probe instead of relying only on editor declarations.
* AVIF/WebP conversion failures now record their exact WordPress image-editor error.
* Added Retry Missing AVIF Only, which preserves existing WebP files and attempts only missing AVIF derivatives.
* Existing optimized files remain untouched and are reused.
* Preserves Pause/Stop/Continue behavior and saved progress.

= 0.2.3 =
* Added Pause, Stop, Continue, Refresh, and Restart From Zero controls.
* Pause and Stop preserve job counters, generated-file results, and completed attachment IDs.
* Continue resumes from the saved position without reprocessing attachments already completed in the job.
* Existing up-to-date WebP/AVIF files are still reused even after a full restart.

= 0.2.2 =
* Increased optimizer batch size from 3 to 10 attachments.
* Increased bounded background work per worker cycle for substantially faster bulk processing.
* Existing up-to-date WebP/AVIF files are reused instead of regenerated.
* Existing running jobs continue from their saved position after updating the plugin.

= 0.2.1 =
* Fixed bulk optimizer jobs remaining at 0% while waiting for WP-Cron.
* Bulk optimization now starts immediately through a secure server loopback worker.
* WP-Cron remains as a fallback if the loopback worker is interrupted.
* Added per-job worker authentication and bounded processing cycles.

= 0.2.0 =
* Added Optimizer module.
* Added WebP and AVIF capability detection.
* Added local WebP/AVIF generation for original and resized images.
* Added background bulk optimization.
* Added optional automatic optimization after new uploads.
* Added optimizer quality settings.
* Originals remain untouched for safety.

= 0.1.3 =
* Replaced broad numeric-ID metadata matching with a targeted smart scanner.
* Stops treating arbitrary numbers in unrelated metadata as media usage.
* Targets WordPress featured images, Gutenberg/classic content, Elementor data, WooCommerce galleries, common media fields, taxonomy image fields, widgets, theme settings, and selected plugin settings.
* Records where a detected image is used, including post/product/term IDs where available.
* Avoids brute-force scanning every postmeta row.
* Keeps secure background processing and page-independent scanning.

= 0.1.2 =
* Scanner now continues server-side after leaving the plugin page.
* Added secure per-scan background worker token with a WP-Cron fallback.
* Browser now polls progress instead of driving the scan.
* Fixed misleading progress display: discovery stages now show database records checked rather than "0 / N media classified".
* Shows media references found during discovery before final classification.
* Keeps third-party notices hidden only on the plugin screen.

= 0.1.1 =
* Dramatically faster staged scanner that reads WordPress tables in batches instead of querying each image repeatedly.
* Added stage-aware progress reporting.
* Cached Media Library dashboard totals for faster page loads.
* Hid unrelated third-party admin notices on the plugin screen only.

= 0.1.0 =
* Initial development release.
* Added Media Health dashboard.
* Added batch-based Media Usage Scanner.
* Added cautious Used / Probably Unused / Needs Review classification.
* Added missing-file detection.
* Added attention-results table.
* No destructive media operations.
