=== WPX Featured Image ===
Contributors: wpxplugin
Author: WPXPlugin
Author URI: https://wpxplugin.com
Plugin URI: https://wpxplugin.com
Tags: featured image, openai, runware, ai image generation
Requires at least: 5.8
Tested up to: 6.6
Requires PHP: 7.4
Stable tag: 2.6.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Find posts without a featured image, generate an image prompt from the title with OpenAI, then generate and attach a featured image using the Runware AI API.

== Description ==

**WPX Featured Image**, developed by [WPXPlugin](https://wpxplugin.com), helps you clean up posts that are missing a featured image:

Everything lives under a single admin menu, **Featured Image**:

1. **Dashboard** — at-a-glance counts of posts with and without a featured image (overall and per post type), a coverage bar, and a **one-click "Generate AI Featured Images"** button (PRO) that automatically runs prompt + image generation for every post missing one, using your default model and prompt template. A live progress bar and run log show exactly what happened to each post.
2. **Missing Images** (PRO) — the detailed, row-by-row tool: lists every post (by type) with no featured image. For each post, click **Generate prompt** to have OpenAI turn the title into a descriptive image prompt (fully editable), then **Generate image** to send it to Runware and set the result as the featured image.
3. **Replace Image** (PRO) — browse any post (with a thumbnail of its current image) and regenerate/replace it, with an option to delete the old image from the Media Library. Filter the list by post type, category, and a date range (or click "All" to reset). Select posts in the normal Posts/Pages list table and choose **"Generate/Replace Featured Image (AI)"** from the Bulk Actions dropdown to land here with exactly those posts pre-loaded.
4. **Settings** — API keys, available Runware models, default model, image size, and the OpenAI prompt template.
5. **Batch runs**: on the Missing Images / Replace Image screens, tick as many rows as you like (or "Select all") and click **"Generate prompt + image for selected"** (or **"Replace Image (1-Click) for Selected"** on the Replace screen) for full control over each prompt and model.
6. **Single-post generation from the post editor**: every public post type gets a "WPX Featured Image" panel in the sidebar of the edit screen, with its own model picker, prompt field, and Generate/Replace button. See **Single Post Guide** in the plugin menu for a step-by-step walkthrough.

== Setup ==

1. Activate the plugin — you'll see a new **Featured Image** item in the admin menu.
2. Go to **Featured Image → Settings** and enter:
   - Your OpenAI API key (and optionally a different chat model, default `gpt-4o-mini`).
   - Your Runware API key.
   - The list of Runware models you want available (one per line, `Label|air-model-id`), and pick a default.
   - The featured image size — pick a preset (Square 1024×1024, Landscape 1200×628 for blog/social, or Widescreen 1600×900) or choose "Custom size" to set your own width/height.
3. Go to **Featured Image → Dashboard** to see your current coverage and run the one-click fix, or **Missing Images** for row-by-row control.

== Notes ==

* Requires an active OpenAI API key with access to a chat-completions model.
* Requires an active Runware.ai API key. See https://runware.ai for pricing and available models.
* Generated images are downloaded into your Media Library like any normal upload, then set as the post's featured image — nothing is hot-linked.
* You can browse additional Runware model identifiers (including community CivitAI models) via Runware's Model Explorer and add them to the "Available models" list in settings.

== Changelog ==

= 2.6.0 =
* **Fixed "Installs" not updating on bestplugintheme.com.** The plugin previously only ever contacted the licensing server once a license key was activated, so free/unlicensed installs were invisible to the marketplace. A new, separate check-in now runs for every install — licensed or not — immediately on activation and weekly afterward.
* New **Telemetry** section on the License screen shows when this site last checked in and lets you change the admin-email opt-in at any time; the choice takes effect immediately (an updated check-in is sent right away).
* License activation/validation/deactivation is unchanged and still requires a license key, as documented.

= 2.5.0 =
* **Missing Images**, **Replace Image**, and the Dashboard's **One-click fix** are now PRO features, gated behind an activated bestplugintheme.com license. A "PRO" badge shows on the relevant menu items, tabs, and dashboard panel until a license is activated; visiting a locked screen shows a "Buy License" / "Activate License" prompt linking to https://bestplugintheme.com/product/wpx-featured-image and the License screen.
* Single-post generation from the post editor sidebar (the "WPX Featured Image" metabox) is unaffected and remains free on every install.

= 2.4.0 =
* Added a new **License** screen (Featured Image → License) to activate, check, and deactivate your bestplugintheme.com license key for this site.
* The plugin now checks in daily with bestplugintheme.com to confirm the license is still valid and report basic install info (domain, plugin version, license status, WordPress/PHP version). This always happens automatically and cannot be turned off, same as any other license check.
* Your site's admin email address is never included in that check-in unless you say yes to a one-time notice — answerable Yes/No, and changeable any time after from the License screen. Nothing else about opting in or out affects the license check-in itself.
* The license is automatically released (deactivated) if you deactivate the plugin, freeing the activation slot for use elsewhere.

= 2.3.2 =
* Dashboard "One-click fix" panel: clarified that each run processes a maximum of 300 posts, and to run it again for sites with more missing images than that.

= 2.3.1 =
* **Found it.** Fixed the actual root cause of "Save Changes not working": the Width/Height number fields had `step="64"`. Selecting the "1200 x 628 (Landscape)" or "1600 x 900 (Widescreen)" preset filled those (now-hidden) fields with values that aren't valid multiples of 64 from the min — e.g. 1200 fails `step="64"` validation. Browsers silently block form submission over an invalid field even when it's hidden, with no visible error, which exactly matched the reported symptom (button appears to do nothing after changing the size preset). Fixed by removing the step restriction and additionally disabling those fields via JS whenever a preset is active, so they're fully excluded from validation.

= 2.3 =
* Added an unmissable, site-wide admin warning that automatically detects if an OLD pre-rename copy of this plugin (from before it became "WPX Featured Image") is still active — this is the single most likely reason a fix wouldn't appear to take effect, since the old and new copies could load side by side without a fatal error and the old plugin's own (un-patched) Settings page might be the one actually being edited.
* Hardened the settings save against stale object-cache reads (Redis/Memcached/managed-host object caching): explicitly clears the relevant cache entries before and after saving, and the form now displays the exact values just submitted rather than a re-fetched (and potentially still-stale) copy.

= 2.2.3 =
* Settings page now shows a specific, visible error instead of failing silently: a distinct message if the security token is invalid/expired (won't save), and a distinct message if WordPress itself reports the database write failed. Added a hidden "form submitted" marker so these cases can be told apart from simply not having saved yet.
* Added an optional debug line (shown only when `WP_DEBUG` is enabled in wp-config.php) at the top of the Settings page showing the plugin version, request method, and whether the form/nonce fields were actually received — useful for diagnosing save issues that don't reproduce in normal testing.

= 2.2.2 =
* **Bugfix**: rebuilt how Settings are saved. Instead of relying on WordPress's Settings API (submitting to `options.php`), the Settings page now verifies its own nonce and saves directly via `update_option()`. The Settings API can fail silently on custom admin pages for several environment-specific reasons (capability filters, option-group registration timing, security-plugin nonce handling); saving directly removes that whole class of problems. Verified end-to-end: values are correctly persisted, the size-preset override still applies, and an invalid/missing nonce correctly blocks the save.

= 2.2.1 =
* **Bugfix**: "Save Changes" on the Settings page was actually saving correctly, but showed no confirmation — because custom (non-native) WordPress admin pages don't automatically display the "Settings saved" notice the way the built-in Settings screens do. Added the missing `settings_errors()` call so a clear "Settings saved." success message now appears after saving.

= 2.2 =
* Settings: added a "Featured image size" dropdown with common presets — 1024 x 1024 (Square), **1200 x 628 (Landscape — blog & social)**, 1600 x 900 (16:9 Widescreen), or Custom (uses the manual width/height fields, still available). The manual fields now only appear when "Custom size" is selected.

= 2.1 =
* Renamed the post-edit sidebar panel from "Featured Image AI" to "WPX Featured Image".
* Added a new "Single Post Guide" page under the WPX Featured Image admin menu — a step-by-step walkthrough (with a preview of the panel) explaining how to generate or replace a featured image directly from the post/page editor.

= 2.0 =
* Restored the logo — now shown ONLY in the plugin's own header (top of Dashboard/Missing Images/Replace Image/Settings), not as the WordPress admin sidebar menu icon (that's back to the plain icon). This was the actual cause of the oversized/overlapping image seen before: the sidebar icon is sized by WordPress core CSS which didn't reliably constrain the large custom image, while the header version has always had explicit sizing. The header logo now also has hard-coded width/height attributes as a second safeguard, so it can never render oversized even if a stylesheet fails to load.
* Re-confirmed the Category/Date filters and the "Replace Image (1-Click) for Selected" button from 1.9 are present and working — if you didn't see them, make sure you fully removed the previous plugin folder before installing this version (see Upgrade Notice below), since re-uploading a zip over an existing plugin folder of the same name is often rejected or skipped by WordPress's uploader rather than overwritten.

== Upgrade Notice ==

= 2.0 =
Please fully deactivate and delete the currently installed "WPX Featured Image" plugin (Plugins screen, or via FTP delete the wp-content/plugins/wpx-featured-image folder) BEFORE installing this zip. Uploading a new zip on top of an existing plugin folder with the same name is often rejected silently by WordPress, which can leave old files in place and hide new features.

= 1.9 =
* Replace Image screen: added Category and Date range (From/To) filters, plus an "All" link to reset filters back to the default view. Pagination now preserves whatever filters are active.
* Replace Image screen: the bulk button for a selection of posts is now clearly labeled "Replace Image (1-Click) for Selected" and runs prompt generation + image generation + replacement in one click for every selected post, in sequence, with progress shown live.

= 1.8.2 =
* Removed the logo image from the header and admin menu — it was rendering oversized and overlapping the sidebar's submenu flyout. Reverted to the clean icon-based header and default menu icon.

= 1.8.1 =
* Fixed the "Buy Now" button URL to https://bestplugintheme.com/product/wpx-featured-image.

= 1.8 =
* Added the official WPX Featured Image logo to the plugin header (replacing the generic icon), and as the admin sidebar menu icon.
* Added a "Buy Now" button next to the WPXPlugin website link in the header.

= 1.7 =
* Menu label now reads "WPX Featured Image" in the admin sidebar.
* Redesigned Dashboard: gradient header, colorful animated stat cards, a shimmering coverage bar, and a highlighted "One-click fix" panel for a more dynamic, modern look.
* Missing Images and Replace Image screens: pagination is now centered with pill-shaped page buttons and a highlighted current page, instead of the default plain WordPress pagination.

= 1.6.1 =
* **Bugfix**: renamed every PHP class, function, constant, AJAX action, and script/style handle from the generic `FIG_`/`fig_` prefix to a unique `WPXFI_`/`wpxfi_` prefix. If an earlier build of this plugin (from before it was renamed to WPX Featured Image) was still installed under its old folder name, activating both at once caused a PHP fatal "Cannot redeclare" error — which also explains the missing admin menu, since the plugin never finished loading.
* **Bugfix**: added a proper double-load guard around the whole plugin and each class file, so accidentally having two copies present no longer fatals.
* **Bugfix**: the "Generate/Replace Featured Image (AI)" bulk action is now registered on `init` instead of immediately when the plugin loads, since built-in post types like `post` and `page` aren't registered yet at that earlier point — this could previously cause the bulk action to silently not appear.
* If you still have the old "Featured Image AI Generator" plugin installed from an earlier version of this build, please deactivate and delete it before installing this version.

= 1.6 =
* New single top-level admin menu ("Featured Image") with Dashboard, Missing Images, Replace Image, and Settings tabs.
* New Dashboard: at-a-glance stats (total posts, with/without a featured image, coverage %) overall and per post type.
* New "One-click fix" panel on the Dashboard: pick a post type and automatically generate prompts + images for every post missing one, with a live progress bar and run log — no manual row-by-row work needed.
* Modernized UI throughout: branded header, tab navigation, stat cards, pills, and a consistent accent color.

= 1.5 =
* Renamed to WPX Featured Image (developed by WPXPlugin, https://wpxplugin.com).
* Added batch generation: select multiple posts on the tool screens and run prompt + image generation for all of them sequentially.
* Added a "Featured Image AI" metabox on the post edit screen for single-post generate/replace.
* Added the "Replace Featured Image" screen and a "Generate/Replace Featured Image (AI)" bulk action on post list tables, with an option to delete the replaced image from the Media Library.

= 1.0.0 =
* Initial release.
