=== PixGlory ===
Contributors: pixglory
Tags: cdn, media, images, offload, performance
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Offload your media library, both new uploads and your existing files, to PixGlory's global CDN and serve it from there, with no theme changes.

== Description ==

Unlike a generic media-offload plugin, PixGlory pairs the offload with a guided migration for
your existing library, a live connection you can watch from your PixGlory dashboard, and
one-click WebP delivery that runs entirely on PixGlory's servers, never on yours.

* **Guided migration, not just new-upload offload.** A read-only scan finds everything eligible
  first; nothing is copied or changed until you say go. Migration then runs in resumable batches
  (safe to close the page, safe if your host interrupts it, never restarts from scratch) and
  rewrites every reference it finds: post content, page-builder layouts including Elementor's
  JSON-based storage, and other plugins' serialized settings. Files are uploaded exactly as
  WordPress generated them, and references switch to the PixGlory URL only once each upload is
  confirmed.
* **Connection-first, watchable from your dashboard.** Once connected, this site shows up live on
  your PixGlory dashboard's Integrations screen: connection status, when it last checked in, and
  a running count of the files it has sent, so you can confirm the plugin is doing its job
  without digging through WordPress admin.
* **One-click WebP delivery, zero re-encoding on your server.** Run an optimisation batch from
  your PixGlory dashboard, and every visitor whose browser supports WebP is served it
  automatically through real content negotiation at the same URL, generated entirely on
  PixGlory's servers. Your WordPress site never runs an image conversion.
* **Free to start.** PixGlory has a free plan this plugin works with; paid plans raise the
  storage and bandwidth limits, with no separate purchase needed for offload or migration.

PixGlory is an image CDN service ([pixglory.com](https://pixglory.com)) with a free plan and
paid plans for higher limits. This plugin is a client for that service: it does not do any image
processing or delivery on its own. An account is required (creating one is free), and use of the
service is governed by PixGlory's [Terms of Use](https://pixglory.com/terms).

With a connection key from your PixGlory organization, this plugin also:

* Pushes newly uploaded images to PixGlory's storage and worldwide CDN after WordPress finishes
  generating its own local size variants. The upload itself is never delayed or blocked by this;
  the push to PixGlory happens afterward, in the background.
* Optionally rewrites your site's image URLs to serve confirmed uploads from PixGlory instead of
  your own server, once PixGlory has confirmed a working URL for that image and not before.
* Never re-encodes or resizes anything on your server. What gets uploaded is exactly the file
  WordPress already generated.
* Never deletes original files from your server. Local copies always stay in place.
* Degrades silently: if PixGlory cannot be reached, or your account is over its quota, uploads
  keep working normally and images keep rendering from your own server.
* Migrates your existing media library, at your own pace, in the background: scans your site
  first (nothing is copied or changed until you start it), then copies files in resumable
  batches and rewrites the links that point at them (post content, page-builder layouts, and
  other plugins' settings) to the PixGlory URL only after each file is confirmed uploaded.
  Nothing is ever re-encoded. Pause and resume any time; your originals are never touched.

**What data is sent where.** No request to PixGlory is made until you paste a connection key on
the PixGlory admin menu and press Connect (this is your explicit consent). See "External services"
below for the exact hosts, when each request fires, and what it carries.

= Migration of an existing library =

Included as of 0.2.0. Open the Migration tab, scan your site (read-only), review what was found,
and start the migration. It runs in the background in resumable batches: safe to close the page,
safe if your host interrupts it, and never restarts from scratch. Nothing is re-encoded: your
existing files are uploaded exactly as they are, and their references are rewritten to the
PixGlory URL only once the upload is confirmed. `wp pixglory migrate` runs the same migration
from the command line, with a `--dry-run` mode.

== External services ==

PixGlory is a paid image CDN service, not a bundled tool: it stores and serves your media on its
own infrastructure, the same way a plugin like Disqus offloads comments to a third-party service.
This plugin is a client for that service and requires a PixGlory account (creating one is free)
and a connection key from that account before it talks to PixGlory at all. It contacts exactly two
kinds of remote host, described in full below, and nothing else. It loads no remote code, script,
style, or font of any kind; every file it runs ships inside the plugin's own files.

**1. PixGlory's API, `https://pixglory.com/api/v1`**

No request reaches this host until you paste a connection key on the PixGlory admin menu and
press Connect, and that action is this plugin's only source of consent. After you connect:

* Every request this plugin makes (a new upload being offloaded, the daily or per-upload
  heartbeat, and the Connection tab's "Test connection" button) carries your site's address and
  its WordPress and plugin version numbers, so your PixGlory dashboard can show the connection as
  active and confirm which versions it is running. This is sent any time the plugin talks to
  PixGlory, whether or not offloading itself is turned on.
* When "Offload new uploads" is on, or while a migration you started is running, this plugin also
  sends the bytes, filename, size, and MIME type of each image being offloaded, and stores the CDN
  URL PixGlory returns as WordPress attachment metadata.
* No other site data (post content beyond the image bytes being sent, user accounts, or other
  plugins' settings) is ever sent to PixGlory.

PixGlory's own site: [pixglory.com](https://pixglory.com). Terms of Use:
[pixglory.com/terms](https://pixglory.com/terms). Privacy Policy:
[pixglory.com/privacy](https://pixglory.com/privacy).

**2. Your own CDN project, e.g. `cdn.pixglory.com/{organization}/{project}` or a custom domain
you attached to it**

If you turn on "Serve from PixGlory," this plugin rewrites your site's rendered image URLs to
point at your own PixGlory CDN project instead of your own server, but only for images you already
offloaded and only once PixGlory has confirmed a working URL for that specific image. This is your
own account's storage serving your own media back to your own visitors, not a third-party asset
load: no visitor's browser fetches anything from a PixGlory host until you have both connected an
account and turned this setting on.

If PixGlory cannot be reached, or your account is over its quota, none of the above blocks or
delays anything: uploads keep working normally and images keep rendering from your own server (see
the FAQ).

== Installation ==

1. Install and activate the plugin.
2. Go to the PixGlory item in the wp-admin menu.
3. On the Connection tab, create a connection key from your PixGlory organization's API keys page
   (pick the project this site should publish into), then paste it in and press Connect.
4. On the Settings tab, turn on "Offload new uploads" and, if you want your site to serve images
   from PixGlory, "Serve from PixGlory".
5. Upload an image to the media library. It should appear on the Status tab as "Served from
   PixGlory" shortly afterward.

== Frequently Asked Questions ==

= Does this plugin work without a PixGlory account? =

No. It is a client for the PixGlory service and requires a connection key from a PixGlory
organization. Creating an account is free, and the free plan works with this plugin; paid plans
raise the storage and bandwidth limits.

= What happens to my existing images? =

Nothing, until you run a migration yourself from the Migration tab (or `wp pixglory migrate`).
Scanning is always read-only. Once you start a migration, files are copied in the background and
their references are rewritten only after each file is confirmed on PixGlory. Your originals are
never deleted or modified on disk, and you can pause or cancel at any point without losing
anything already copied.

= Does migration rewrite everything that references an image? =

Post content, page-builder layouts (including Elementor's JSON-based storage) and other plugins'
serialized settings are all handled. Post revisions are deliberately not rewritten: restoring an
old revision may show a locally served image again, which is harmless since your originals are
kept, but is worth knowing if you use revisions heavily.

= What happens if PixGlory is unreachable? =

Uploads to your media library are never blocked or delayed by this plugin. If a push to PixGlory
fails, the image simply keeps rendering from your own server, the plugin retries automatically for
transient failures, and the reason is recorded on the Status tab.

= Does deactivating or deleting the plugin break my images? =

No. Deactivating stops new offloading and URL rewriting; every image that was being served from
PixGlory reverts to rendering from your own server, which still has the original file (this plugin
never deletes originals). Deleting the plugin additionally removes its own settings.

= Why does my dashboard show the site as last synced a while ago? =

This plugin checks in with PixGlory on every image upload, and once a day even if nothing was
uploaded, so a quiet site still shows as connected instead of going stale. Both of those check-ins
run on WordPress's own background scheduler (WP-Cron), which only fires when your site gets a
visit, so a low-traffic site can fall behind its own schedule. If you want the daily check-in to
land on time regardless of traffic, point a real system cron job at your site's wp-cron.php on a
schedule (most hosts document how, and this is standard WordPress advice independent of PixGlory)
instead of relying on visits to trigger it.

== Screenshots ==

1. The Connection tab, connected to a site.
2. The Settings tab.
3. The Migration tab, showing what a scan found.
4. The Migration tab, mid-run: progress bar, batch counter, and the copied, remaining and skipped tiles.
5. The Migration tab, after a migration finishes.
6. The WordPress media library, with the Served from PixGlory badge on offloaded items.
7. The Status tab.
8. The PixGlory dashboard's Integrations screen, showing the connected WordPress site.

== Changelog ==

= 1.0.0 =
* First release on the WordPress.org plugin directory: offload new uploads to PixGlory's global
  CDN, migrate an existing media library in resumable background batches (read-only scan,
  serialize-aware and Elementor-JSON-aware link rewriting), and optionally serve confirmed
  uploads from PixGlory instead of your own server. Works with PixGlory's free plan.
* Adds a daily heartbeat (via Action Scheduler) so a quiet site with no uploads still checks in
  and shows correctly on the PixGlory dashboard, and corrects dashboard copy that previously
  promised data the plugin does not track.
* Points the "create a connection key" hints and the connect-form helper at the PixGlory
  dashboard's Integrations screen now that it exists.
* Inserting an image in the block editor now stores your site's own local address in the post,
  not a PixGlory link, so your content still points at a real file even if you later disconnect
  or delete the project; the page itself keeps serving from PixGlory's CDN while connected either
  way. A new "Restore local image URLs" action (Connection tab, WP-CLI's
  `wp pixglory restore-local-urls`, and a best-effort pass on uninstall) finds any PixGlory link
  written into a post by an earlier version of this plugin and points it back at your own server.
* Fixes the Migration tab's counters: the Remaining tile no longer reads 0 before the first batch
  finishes, the in-progress header no longer shows "Batch 0 of N" before the first batch starts,
  and the scan results panel now states its file count includes every size WordPress generated,
  bridged to the number of media items those files belong to.
* Fixes a bootstrap timing bug where the bundled background job library could fail to load on a
  site where no other plugin loads its own copy first, which stalled every Migration scan at "0 of
  about 0 items checked" and silently skipped the daily connection check-in.
* Updates the bundled Action Scheduler library to 4.1.0.
* Validates every stored PixGlory URL against this connection's own confirmed destination before
  it is ever substituted into a post, a page builder's layout, or a rendered image tag, so a
  corrupted or unexpected stored value can never end up in your site's output.

= 0.3.0 =
* Sends your site's address and WordPress/plugin version numbers with every API request, so your
  PixGlory dashboard can show this connection as active and which versions it's running.

= 0.2.0 =
* Migration of an existing media library: read-only scan, resumable batched transfer, and
  serialize-aware/JSON-escape-aware reference rewriting for post content, Elementor layouts, and
  other serialized meta and options. Pause, resume, and cancel (without rollback). `wp pixglory
  migrate` WP-CLI command with a `--dry-run` mode.
* Raised the minimum supported PHP to 8.1 and WordPress to 6.5.
* Bundled Action Scheduler for the migration's batch queue.

= 0.1.0 =
* Initial release: connect flow, settings, new-upload offload, and URL rewriting for confirmed
  uploads.

== Upgrade Notice ==

= 1.0.0 =
First release on the WordPress.org plugin directory. No breaking changes for existing installs.
Content now stores your site's own local image address rather than a PixGlory link; run
"Restore local image URLs" (Connection tab) once to update any post saved before this change.

= 0.3.0 =
Every API request now also reports your site's address and version numbers, so your PixGlory
dashboard can show this connection as active. See "What data is sent where" above.

= 0.2.0 =
Adds migration of your existing media library. Raises the minimum PHP to 8.1 and WordPress to 6.5.

= 0.1.0 =
Initial release.
