# CHANGELOG

## [1.0.8]

### Added
- **Pair: AI Image Optimizer** — „Optimize image” w Media Library + dashboard callouts (`AIMT_Integrations`).

## [1.0.7] - 2026-06-05

### Added
- **Used-Only Autopilot** — statystyki i karta dashboard: AI tylko dla obrazów faktycznie użytych na stronie (`AIMT_Autopilot`).
- Opis przy ustawieniu `only_used_images`.

## [1.0.6] - 2026-05-28

### Added
- **Pair: AI Alt Translator** — link „Translate ALT” w Media Library gdy Alt Translator aktywny.
- Hook `aimt_metadata_applied` po generate metadata (`AIMT_Integrations`).

## [1.0.3] - 2026-06-14

### Added
- **Review prompt** after 14 days of meaningful use (API tested, scan, or background job):
  “Enjoying AI Media Toolkit?” banner with Rate / Maybe later / Don’t ask again.
  Review link defaults to `https://pewitlabs.com/reviews/` (filterable; WP.org when live).

## [1.0.2] - 2026-06-14

### Added
- **Settings → Image sent to AI (metadata)**: choose which WordPress size is uploaded to OpenAI
  for ALT/title/caption/description (`large` ~1024 px default, `medium_large`, max 800 px,
  `medium`, or full original). Reduces API payload size and bulk job time vs sending full files.

## [1.0.1] - 2026-06-14

### Fixed
- **Backup ZIP download**: `Create ZIP` built the archive but did not start a download — the
  authenticated download handler (`aimt_download`) was never registered on `admin-ajax.php`.
  Downloads now work via the registered handler; client trigger uses a direct link click instead
  of a hidden iframe (more reliable in modern browsers).
- **Save settings with stored API key**: saving other settings no longer clears the OpenAI key
  when the key field is empty (edit field is blank by design after masking).

### Changed
- **API key masking (Settings)**: a saved key is shown as `••••••••` plus the **last 4 characters**
  only — the full key is not rendered in HTML/DOM. Use **Change key** to enter a new key;
  **Cancel** returns to the masked view.
- **Admin tab layout**: Context, Language, Reports, Images, Recovery, and Settings subpages use
  consistent form cards, full-width fields, and section headers. Reports no longer incorrectly
  includes the Featured image AI block (stays under Settings). Images filters/actions use a
  cleaner grid; backup table action buttons wrap properly.

### Added
- `aimt_api_key_masked_label()` helper and `mask` field in successful API test responses.
- i18n strings for section help text and per-tab save actions (Reports, etc.).

## [1.0.0] - 2026-06-14

### Added
- **Change history UI**: open Details on any image to see logged metadata/filename changes and
  restore a previous state (Pro).
- **First-run onboarding** wizard (API → scan → generate).
- **Broken / missing sizes** detection in quality analysis, new Images filter, and report summary.
- Bulk actions: **Regenerate thumbnails (selected)** and **Repair selected (main file)** (Pro).

### Changed
- Version badge no longer shows “Alpha”; stable **1.0.0** release.
- ROADMAP updated to reflect shipped vs post-1.0 items.

## [1.0.0-alpha.7] - 2026-06-14

### Added
- Settings action: **Generate featured images for missing posts** (Pro). Starts a
  background job that finds published posts without a featured image and creates one
  from title + content (one post at a time, uses your style/model settings).

## [1.0.0-alpha.6] - 2026-06-14

### Added
- Settings checkbox: **Auto-generate featured image on publish when missing** (Pro). On
  publish/update, if the post has no featured image, one is created from title + content
  using your style preset and custom prompt.

## [1.0.0-alpha.5] - 2026-06-14

### Added
- Featured image settings: **visual style preset** (photography, illustration, European /
  African / Asian aesthetic, multicultural) plus a **custom style prompt** textarea for
  mood, colors, composition and other image-generation rules.

## [1.0.0-alpha.4] - 2026-06-14

### Added
- **Featured image AI** (Pro): generate a featured image from the post title and content
  directly in the post editor (Gutenberg sidebar + classic editor meta box). The image is
  uploaded to Media Library, set as featured image immediately, and can optionally receive
  full ALT/title/caption/description.
- Settings: enable/disable post editor panel, image model (DALL·E 3 / 2 / GPT Image 1),
  size and auto-metadata for generated images.

## [1.0.0-alpha.3] - 2026-06-14

### Added
- **Native WordPress Media Library** panel on each image: generate ALT, title, caption &
  description in one click, plus **Change filename** (Pro). Also available as list-row
  quick actions on `upload.php`.
- API readiness gate: generation requires a saved **and tested** OpenAI key; otherwise a
  link to plugin Settings is shown.
- Settings: info icon next to the API key field with a hover tooltip explaining how to
  create a key on platform.openai.com.

### Changed
- Single-image generation now validates API key status server-side (`api_key_verified`).
- Media Library generate uses `regenerate_all` so all configured metadata fields are written.

## [1.0.0-alpha.2] - 2026-06-14

### Changed
- Sidebar navigation now switches workspace sections one at a time (Dashboard, Images,
  Tasks, Recovery, SEO Filenames, Language, Context, Reports, Settings) — matching
  the design mockup instead of scrolling a single long page.
- WordPress submenu pages open the matching workspace tab automatically.

### Added
- **Change filename** button on each row in the Images table for single-file SEO rename
  (Pro): suggests a filename from usage context, confirms, then renames in place.

## [1.0.0-alpha.1] - 2026-06-13

### New — Admin UI redesign (PEWIT Labs design system)
- Complete visual refresh matching the Freemius design canvas: Geist typography, blue
  primary palette (#2f6bff), rounded cards, modern sidebar navigation with SVG icons.
- New app toolbar with gradient logo mark, Alpha version badge and plan badge.
- Dashboard hero with 4 KPI stat cards (library size, missing ALT, incomplete, health score)
  and quick-action buttons.
- Light-themed Activity log sidebar (replacing the dark console style).
- Styled forms, tables, backup panel, progress bars, banners and buttons throughout.
- Beginner-friendly OpenAI API key help (collapsible guide in Settings).

### Changed
- Manual recovery snapshots run in batches with live progress on the button.
- Backup ZIP / CSV downloads start automatically via a hidden iframe; correct MIME types.

## [0.9.9.2] - 2026-06-13

### Changed
- Manual recovery snapshots now run in batches with a live progress indicator
  (`processed/total (%)` on the button) instead of one long blocking request. Avoids the
  "is it doing anything?" uncertainty and request timeouts on large libraries.

### Fixed
- Backup ZIP / CSV report downloads now start automatically (programmatic same-tab download)
  instead of relying on a `target="_blank"` link that browsers/popup-blockers could silently
  drop ("clicked download, nothing happened"). A manual fallback link is still shown.
- Authenticated download handler now sends the correct MIME type per file (`text/csv` for
  reports, `application/zip` for backups) so browsers keep the right extension instead of
  saving CSV reports as `.txt`.

## [0.9.9] - 2026-06-13

### Security
- Backup and report directories under `wp-content/uploads/` are now access-protected on
  creation: a blank `index.php` (no listing) plus an `.htaccess` "deny all" rule
  (`aimt_protect_dir()`). Prevents enumeration/download of image backups, manifests
  (post content) and CSV reports (S1/S3).
- Backup ZIPs and CSV reports are no longer exposed via a public uploads URL. They are
  streamed through a new authenticated handler (`AIMT_Admin::ajax_download`) that enforces
  `manage_options` + a nonce and resolves the file path from a validated id/basename
  (`AIMT_Backup::zip_path_for()`, `AIMT_Analyzer::report_path_for()`).
- CSV exports (analysis report + background-job report) now neutralize formula/CSV injection
  by escaping cells that begin with `= + - @` tab or CR (`aimt_csv_safe()`) (S2).
- Backup ZIP path is derived from the validated operation id instead of the raw request
  value (S4, defense-in-depth).

## [0.9.8] - 2026-06-13

### New
- "Your plan" panel in the admin: a plan badge in the header (Free/Pro/Agency), a status bar for
  paid users with "Manage license & invoices" (Freemius account) and contextual upgrade links
  (`aimt_account_url()`, `aimt_plan_label()`).
- Agency white-label: settings to set a custom brand name and logo that replace "AI Media Toolkit"
  in the admin menu, dashboard header and background-job emails (`aimt_whitelabel()`,
  `aimt_brand_name()`); only active on the Agency plan.

## [0.9.7] - 2026-06-13

### New
- Free/Pro/Agency feature gating. Free keeps single-image generation, library scan and a
  basic CSV report; Pro/Agency unlock the background queue & bulk generation, bulk SEO
  rename, replace-in-place, backups/recovery, emergency repair, duplicate/quality analysis
  and email reports.
- Upgrade UX for free users: an "Upgrade to Pro" banner, `PRO` pills on locked actions and
  in-context upsell notices using the Freemius upgrade URL (`aimt_upgrade_url()`).

### Security
- Server-side enforcement (`AIMT_Admin::require_pro()`) on all Pro-only AJAX endpoints and
  Media Library bulk actions, so the gate cannot be bypassed from the client.

## [0.9.6.1] - 2026-06-13

### Changed
- First build packaged for Freemius deployment (premium/free auto-split). No functional
  changes versus 0.9.6; version bump for the initial Freemius upload.

## [0.9.6] - 2026-06-13

### New
- Re-added the Freemius licensing bootstrap (was missing in 0.9.5) so Pro/Agency licensing
  and auto-updates can be enabled once credentials are set.
- Bundled the Freemius WordPress SDK at `vendor/freemius/`.
- Added license helpers `aimt_plan()`, `aimt_is_pro()`, `aimt_is_agency()` with an
  `AIMT_DEV_PLAN` constant override for local testing (no feature gating yet).

### Changed
- Added the Freemius `set_basename()` guard so the free version auto-deactivates when the
  premium version is activated.
- Moved uninstall logic into a Freemius `after_uninstall` handler and removed `uninstall.php`
  so Freemius can report the uninstall event (settings are still kept by default during beta).

### Fixed
- Hardened `AIMT_License::is_pro()` / `plan_label()` so they no longer fatal when the
  Freemius SDK is absent or credentials are placeholders (free-only mode).

### Notes
- The plugin stays in free-only mode until the real Freemius Plugin ID and Public Key are
  filled into `ai-media-toolkit.php` and `is_live` is set to `true` after sandbox testing.

## [0.9.5] - 2026-06-13

### Fixed
- Fixed legacy Media submenu URL by redirecting `upload.php?page=ai-media-toolkit` to the new top-level admin page.
- Fixed SEO filename generation producing too-long product filenames.
- Fixed duplicate/repeated filename tokens such as repeated product attributes.
- Fixed size values such as `34-36-38-40` dominating generated filenames.

### Improvements
- Improved product filename cleanup for WooCommerce galleries.
- Improved filename language normalization for EN/PL product names.
- Improved filename length defaults for safer WooCommerce media management.

### Known Issues
- Some already renamed files may need a second pass using the SEO Rename screen to shorten older long filenames.

## [0.9.4] - 2026-06-13

### New
- Added top-level WordPress admin menu with planned submenus: Dashboard, Generate, Images, SEO Rename, Backup & Recovery, Reports and Settings.
- Added backup snapshot delete action.
- Added optional automatic attachment title update after SEO filename rename.

### Improvements
- Improved filename rename reporting with old filename → new filename.
- Improved live list refresh during active jobs so filtered views update while processing.
- Improved email report filename change lines.
- Updated admin links to the top-level AI Media Toolkit page.

### Fixed
- Fixed confusing rename UX where file name changed but attachment title stayed as the old upload filename.
- Fixed backup management missing delete action.

## [0.9.3] - 2026-06-13

### Fixed
- Fixed SEO filename generation using the default/original product language instead of the current WPML/Polylang language.
- Fixed EN queue items receiving Polish filename parts such as `sukienki-damskie`.
- Filename generation now passes the current queue language into the filename builder.

### Improvements
- Filename builder now resolves translated product/page/category context before creating the slug.
- Added fallback normalization for common Polish WooCommerce terms when generating EN/ES filenames.
- Reduced language noise in filenames so ALT-like phrases are not copied into the file name.

### Known Issues
- Existing wrongly named EN files need to be reprocessed with SEO rename to update their slugs.

## [0.9.2] - 2026-06-13

### New
- Added full admin UI design specification in `docs/APP_DESIGN_SPEC.md`.
- Added tab-based admin navigation foundation.
- Added expanded JavaScript translation dictionary for the admin application.
- Added Polish translation coverage for admin labels, buttons, statuses and job messages.

### Improvements
- Rebuilt admin layout visually around Dashboard, Images, Jobs, Recovery, SEO Filename, Language, Context, Reports and Settings sections.
- Improved admin spacing, cards, status badges, sticky action bar and live log usability.
- Improved translation fallback for hardcoded legacy UI strings using a JavaScript label map.
- Improved layout for long settings fields, model fields, status badges and filters.

### Fixed
- Fixed multiple untranslated admin UI strings from previous beta builds.
- Fixed inconsistent admin labels in the Media Toolkit panel.

### Known Issues
- Some older dynamically generated log entries may still contain English values if they were saved before the translation system was enabled.

## [0.9.1] - 2026-06-13

### New
- Added translation-ready foundation for WordPress internationalization.
- Added `/languages/ai-media-toolkit.pot` translation template.
- Added Polish translation files: `ai-media-toolkit-pl_PL.po` and `ai-media-toolkit-pl_PL.mo`.
- Added `docs/APP_UI_STRUCTURE.md` with the full recommended UI/tab layout.
- Added `docs/I18N_TRANSLATION_GUIDE.md` with translation rules for PHP and JavaScript.

### Improvements
- Added `Domain Path: /languages` to the plugin header.
- Added `load_plugin_textdomain()` support through the new `AIMT_I18n` class.
- Added localized JavaScript string object for common admin UI actions and notices.
- Updated key admin labels and buttons to use WordPress translation functions.

### Fixed
- Prepared the plugin for Polish WordPress admin UI without requiring hard-coded Polish labels.

### Known Issues
- Some older dynamic JavaScript messages may still be hard-coded and should be moved into the JS i18n object before 1.0.0.
- Remaining developer/debug strings should be reviewed during the 1.0 translation freeze.

## [0.9.0] - Safety & Recovery System

### New
- Added automatic safety snapshots before risky operations: rename, replace, metadata rewrite and recovery repair.
- Added backup storage under `wp-content/uploads/ai-media-toolkit-backups/`.
- Added backup of original image file, attachment metadata and WooCommerce product/gallery relations.
- Added manual recovery snapshot button.
- Added backup list panel in plugin admin.
- Added one-click rollback for saved backup operations.
- Added ZIP export for backup operations when `ZipArchive` is available.

### Improvements
- Risky background jobs now create a backup operation automatically.
- Rename and replace operations back up attachments before touching files.
- Emergency repair backs up an attachment before changing the main file path.
- Settings now include backup retention and backup behavior controls.

### Fixed
- Reduced risk of irreversible product image damage during SEO filename operations.
- Added recovery path for file/metadata/WooCommerce relation restoration.

### Known Issues
- ZIP export requires PHP `ZipArchive` support.
- Very large media libraries may produce large backup directories. Use retention cleanup.

## [0.8.15] - 2026-06-12

### Fixed
- Fixed emergency Woo repair timing out with HTTP 504 on larger stores.
- Emergency repair now runs in small AJAX batches instead of one long request.
- Added live recovery progress: processed, repaired, unresolved, skipped and remaining.

### Improvements
- Recovery state is persisted in `wp_options` while the repair runs.
- Repair button now keeps running batches until the broken image list is complete.

## [0.8.14] - 2026-06-12

### Fixed
- Added Deep Recovery fallback for WooCommerce images damaged by filename rename operations.
- Improved recovery candidate matching when the current attachment path points to a 100x100 thumbnail or missing file.
- Recovery now searches the upload month folder, ignores generated thumbnails and uses a confidence score before assigning a replacement file.
- Added protection against selecting generated sizes like `150x150`, `300x300`, `768x` as the main attachment file.

### Improvements
- Recovery report now includes candidate confidence and reason data.
- Emergency repair is more conservative to avoid assigning the wrong image to a product.

### Known Issues
- Deep Recovery can only repair images if a suitable original or large derivative still exists in `wp-content/uploads`.
- If several unrelated large images exist in the same upload folder and no history/metadata hint is available, low-confidence candidates are left unresolved instead of being guessed.

## [0.8.12] - Emergency Woo image repair

### Fixed
- Added emergency protection against using generated thumbnails as main attachment files during SEO rename.
- Added automatic repair for attachments whose main file points to a small thumbnail after rename.
- Improved missing file path repair to prefer the largest original image candidate instead of the first matching thumbnail.
- Added admin action to scan WooCommerce images and repair broken/small main attachment files.
- Added safety stop: filename rename is refused when the current attachment file looks like a generated thumbnail or is below the configured minimum image size.

### Important
- Bulk filename rename should be paused until this version is installed and the emergency repair scan is run.

## [0.8.11] - 2026-06-12

### Fixed
- Fixed missing file errors by adding automatic attachment path repair before metadata generation.
- Fixed overly long SEO filenames that copied full ALT-style sentences.
- Fixed job completion stats when total count became stale after interrupted or older queue runs.
- Fixed missing step in logs by adding Step 5/6: Update attachment metadata.

### Improvements
- Improved filename intelligence: product/page title, category and key attributes are prioritized.
- Added richer failed item diagnostics: ID, context, language, step, filename and expected path.
- Added documentation for stability and filename repair changes.

### Known Issues
- Auto-repair can only fix missing file paths if a matching file still exists on the server.

## [0.8.10] - 2026-06-11

### New
- Added detailed live processing log with Processing ID, filename, context/product, language and step number.
- Added current processing panel for active background jobs.
- Added email report levels: Basic, Detailed and Full.
- Added optional CSV report attachment for completed jobs.

### Improvements
- Improved background job reporting for metadata generation and filename rename jobs.
- Improved status column width and badge wrapping in the image list.
- Improved notification emails with filename changes and failed item lists.

### Fixed
- Fixed unclear activity log entries that did not show which image/product was currently processed.

## [0.8.9] - 2026-06-11

### New
- Added Admin UX Overhaul with compact image rows and expandable details.
- Added sticky Live Activity Log with success, warning, error and info entries.
- Added log export and clear actions.

### Improvements
- Improved image table readability for large libraries.
- Replaced long metadata columns with compact metadata flags.
- Added status badges for missing ALT, incomplete metadata, skipped items and language.
- Improved filename display with truncation and full-name tooltip.
- Improved activity feedback during scan, generation, background jobs and rename jobs.

### Fixed
- Reduced oversized table rows caused by long ALT/caption/description text.
- Fixed poor screen usage in the image list on large WooCommerce/WPML sites.

## [0.8.8] - Multilingual queue + filename action fix

- Fixed filtered multilingual jobs where rows in different languages could be collapsed into fewer processed items.
- Fixed `Generate ALL matching filter + filename` so it actually attempts filename rename for every matching supported item, not only files detected as "bad".
- Added language override support for queued generation entries.
- Improved SEO filename detection: filenames with underscores are treated as weak SEO filenames.
- Improved SEO filename slug cleanup by converting underscores to hyphens.

## [0.8.7] - Finished job time hotfix

- Fixed completed background jobs continuing to recalculate average time after the job has finished.
- ETA now freezes at `0s` when a job is completed or stopped.
- Added stable finished time display.
- Job finish time now uses the WordPress timezone and time format via `wp_date()` where available.
- Updated browser-side ETA fallback so it does not run for completed/stopped jobs.

## [0.8.6] - Rename/replace thumbnail repair

- Added automatic thumbnail regeneration after SEO filename rename.
- Added repair step after replacing media files while keeping the same attachment ID.
- Added raw URL replacement for generated image sizes where possible.
- Added WooCommerce product image cache clearing after rename/replace.
- Added repair summary in the replace/rename result panel.
- Added `docs/RENAME_THUMBNAIL_REPAIR.md`.

## [0.8.5] - ETA hotfix

- Fixed ETA calculation for background jobs.
- ETA now appears after 3 processed items.
- Added backend timestamps: `first_progress_ts`, `last_progress_ts`, and `last_done_count`.
- Added browser-side ETA fallback when an already-running upgraded job has no usable timestamps.
- Added images/minute and estimated finish time display when available.

## [0.8.4]

- Added server-side pagination for the image list.
- Added filters for missing ALT, incomplete metadata, bad filenames, supported and skipped items.
- Added search across filename and detected usage.
- Added Generate visible page, Generate ALL matching filter and Generate ALL + SEO filename actions.
- Added email notifications when background jobs complete, including failed/skipped counts and duration.
- Added notification settings with recipient and minimum job duration.
- Improved background jobs with ETA and combined metadata + filename pipeline.

## [0.8.3]

- Added Bulk SEO Rename background jobs.
- Added rename bad filenames only mode.
- Added rename all listed images mode.
- Improved SEO filename builder using WooCommerce product title, categories, attributes, page/post title and existing ALT text.
- Added ETA and average time display for background jobs after a few processed items.
- Added PEWIT Labs branding placeholder.
- Added Media Library bulk action for bad filename rename only.

## [0.8.2] - Usage detection hotfix

- Added usage detection mode: Strict, Balanced and Debug.
- Strict mode now hides noisy generic `post_meta` references by default.
- Added usage confidence labels: primary, gallery, meta only.
- Reduced false positives in the “Used in” column, especially on WooCommerce / ACF-heavy sites.

## [0.8.1] - Hotfix

- Fixed scan getting stuck on larger sites by replacing repeated per-image usage scans with a single usage map pass.
- Improved AJAX error reporting when scan/API requests fail.
- Fixed admin layout width issues for model/min width/min height fields.
- Improved responsive layout for settings and action panels.

## [0.8.0]

- Added duplicate metadata detection.
- Added similar metadata detection.
- Added bad filename detection.
- Added basic wrong-language metadata detection.
- Added media quality score.
- Added CSV report export.
- Added Media Library bulk actions for metadata generation and SEO rename.
- Added safety settings and metadata/filename history logging.
- Added more detailed scan counters: missing title, caption and description.
- Added documentation for test plan, monetization and duplicate analysis.

## [0.7.1]

- Added replace file while keeping attachment ID.
- Added SEO filename suggestions from page/post/product usage.
- Added safe filename rename without changing attachment ID.

## [0.7.0]

- Added background generation core.
- Added scan improvements.
- Added multilingual detection base.

## [0.6.x]

- Stabilized API handling, counting and plugin update folder.
