=== Dyadikosnous Media Converter ===
Contributors: dyadikosnous
Tags: webp, images, woocommerce, optimization, media library
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 11.1
Stable tag: 1.1.10
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Shrinks complete media families transactionally, preserves attachment IDs, rewrites URLs, and audits unused images.

== Description ==

Dyadikosnous Media Converter works as a standalone WordPress Media Library tool; WooCommerce is optional. When WooCommerce is active, product, gallery, variation, order-meta, image-size, cache, and HPOS compatibility integrations are enabled automatically.

It provides three deliberate workflows:

* A resumable library conversion with a progress bar.
* Automatic optimization after new image uploads.
* A conservative unused-attachment audit followed by explicit trash or permanent deletion.

The converter keeps the existing attachment ID, so featured images, page-builder media, taxonomy images, and—when WooCommerce is active—product galleries and variation images continue to resolve normally. It regenerates every image size currently registered by WordPress, the theme, and active plugins. Literal old URLs are replaced in pages, posts, custom post types, taxonomy descriptions and metadata, options, JSON, PHP-serialized builder data, and eligible custom prefixed tables.

The 1 MB limit is enforced on the full WebP and all generated sizes. Encoding begins at the preferred quality, lowers quality to the configured floor, then reduces dimensions if necessary.

A conversion is committed only when the complete resulting attachment family uses less disk space than the existing family. Equal-size or larger results are rolled back and reported as failures, leaving the original attachment unchanged.

Unlike format-only converters, the plugin measures the full attachment family—including every registered WordPress, theme, builder, and optional WooCommerce size—before committing a conversion. It also preserves attachment IDs, safely rewrites literal URLs in structured data, and provides a conservative unused-media audit in the same resumable workflow.

== Important safety notes ==

* Make a verified database and uploads backup first.
* Test the complete workflow on staging before production.
* Purge page, object, builder, CDN, and reverse-proxy caches after a batch.
* The plugin processes WordPress Media Library attachments. It does not rename theme/plugin assets or remote images that WordPress does not own.
* An unused scan cannot see references hard-coded in PHP, held by a remote service, or stored in an inaccessible external system. Ambiguous scans are marked Review and excluded from bulk deletion.
* Animated GIF protection is enabled by default because common WordPress image editors can flatten animations.

== Installation ==

1. Copy this folder into `wp-content/plugins/` or upload its ZIP in Plugins > Add New.
2. Activate the plugin.
3. Confirm that the “WebP ready” indicator appears under Media > Dyadikosnous Media.
4. Review Settings, take a backup, then start the optimizer.

== Frequently Asked Questions ==

= Does this require WooCommerce? =

No. The plugin activates and processes WordPress Media Library images without WooCommerce. It scans pages, posts, custom post types and taxonomies, blocks, builder data, options, metadata, and eligible custom tables. WooCommerce-specific product, gallery, variation, order-meta, cache, and HPOS behavior is enabled only when WooCommerce is installed and active.

= Does this support WooCommerce products and variations? =

Yes. Conversions keep the existing attachment records and IDs. Variation featured images, gallery membership, gallery order and colour-specific assignments are preserved. WooCommerce image sizes are regenerated from the new WebP file, and referencing product/variation caches are refreshed. Unused-image checks recognize numeric IDs, comma-separated galleries, serialized arrays and JSON regardless of the metadata key used by a theme or extension. Ambiguous serialized objects are retained conservatively.

= What if a variation still shows a broken image after an earlier conversion? =

Run the optimizer again after updating the plugin to refresh stale image caches. Already-compliant WebP images are not converted again, but their referencing products, variations, and parent product caches are refreshed. Existing image assignments are preserved. Purge any external page or CDN cache afterward. This does not restore missing attachment records or repair gallery IDs that no longer resolve.

= How do I check broken variation galleries? =

Open Tools > Variation Gallery Audit and scan the catalog. The optional, read-only audit checks WooCommerce featured images, parent galleries and supported additional variation galleries, including current and legacy Woodmart fields. Download the issue report to see affected products and variations, unresolved image IDs, any remaining original/current filenames, and filenames or deletion results retained in current and older plugin job logs. It reports problems without changing assignments or storefront responses. Recovery of already-missing attachments requires a verified mapping or an earlier database backup; a numeric ID alone cannot identify the original photo.

= Is the plugin compatible with High-Performance Order Storage (HPOS)? =

Yes. The plugin declares HPOS compatibility. It operates on Media Library attachments and preserves their IDs; it does not read or write WooCommerce order storage.

= What does “Preserve the uploaded original” keep? =

It keeps one source master for recovery. Superseded JPEG/PNG/GIF thumbnail files are removed. Turning the setting off on a later optimization removes source masters previously retained by this plugin.

= Is every output guaranteed to be below 1 MB? =

Successful conversions are strictly below 999,000 bytes. If the configured safeguards cannot reach that size, the item fails and its original attachment metadata remains in place.

= Can a successful conversion increase disk usage? =

No. The plugin compares the complete existing and proposed attachment families before deleting or rewriting anything. A proposed WebP family that is not smaller is removed, and the original attachment remains unchanged.

= Can I close the browser? =

The current sequence pauses when the page closes. Open the page and start the same job type again to resume the active job. Each completed attachment remains completed.

== Changelog ==

= 1.1.10 =
* Recognize attachment IDs in comma-separated, serialized and JSON gallery values without relying on theme-specific metadata key names.
* Refresh referencing product, variation and child-variation caches for custom gallery metadata while preserving attachment IDs and saved gallery order.
* Retain ambiguous serialized objects during unused-image cleanup without instantiating their classes.
* Remove the Woodmart storefront fallback introduced in 1.1.9. Keep the optional variation gallery audit read-only and leave gallery rendering and reassignment to the site.

= 1.1.9 =
* Fix unused-media detection for current and legacy Woodmart galleries, so gallery-only images are retained during cleanup.
* Prevent unresolved Woodmart gallery entries from rendering "undefined", while preserving saved gallery IDs and every usable variation image.
* Add a read-only catalog-wide Variation Gallery Audit under Tools, with batched scanning and CSV export of broken references and surviving filename history.
* Retain the filename in future unused-image deletion results to help identify deleted media in job history.
* Clarify that cache refresh does not recover deleted attachments or reconstruct missing colour-specific gallery mappings.

= 1.1.8 =
* Refresh image-related product, variation, and parent product caches immediately after conversion, including shared featured and gallery images.
* Clear Woodmart variation swatch caches and recognize its current and legacy additional variation gallery assignments.
* Refresh WooCommerce caches for already-compliant WebP images so rerunning the optimizer can repair stale image URLs without reassigning images.

= 1.1.7 =
* Publish a maintenance release through the WordPress.org update channel.

= 1.1.6 =
* Make WooCommerce optional so the plugin activates and processes the WordPress Media Library on non-WooCommerce sites.
* Keep product, variation, order-meta, image-cache, and HPOS integrations conditional on WooCommerce being active.
* Add taxonomy-description URL replacement and integration coverage for pages, posts, custom post types, builders, and custom taxonomy metadata.

= 1.1.5 =
* Declare compatibility with WooCommerce High-Performance Order Storage (HPOS).
* Verify the compatibility registration against WooCommerce during integration testing.

= 1.1.4 =
* Rename the plugin and slug to a distinctive, trademark-safe identity for WordPress.org review.
* Align the main filename and translation domain with the requested slug.
* Declare WooCommerce as a plugin dependency and correct the contributor username.

= 1.1.3 =
* Roll back a conversion when its complete WebP family would not reduce disk usage.
* Keep the original attachment, metadata, MIME type, and files unchanged after a size-reduction rejection.

= 1.1.2 =
* Report a net storage increase instead of incorrectly flattening it to “0 B saved”.
* Refresh filesystem size information after replacing generated images so savings use current file sizes.

= 1.1.1 =
* Align the text domain, main plugin filename, and package directory with the final WordPress.org plugin slug.

= 1.1.0 =
* Prepare the plugin for WordPress.org with a compliant slug, text domain, package metadata, and unique code prefix.
* Replace discouraged filesystem calls and harden preserved-original path validation.
* Improve admin accessibility, JavaScript internationalization, and release packaging.

= 1.0.2 =
* Remove the direct PHP logging call from AJAX recovery so restricted hosting environments cannot turn diagnostics into a fatal error.
* Skip opaque serialized plugin objects whose PHP class is unavailable, preventing incomplete-object failures without corrupting third-party data.

= 1.0.1 =
* Show actionable HTTP, session, timeout, network, WordPress, and PHP processing errors instead of a generic request failure.
* Recover WordPress JSON when another component prints a PHP notice or warning before it.

= 1.0.0 =
* Initial release.
