=== StagePatch ===
Contributors: hexcorp
Tags: staging, deployment, content sync, migration, woocommerce
Requires at least: 6.4
Tested up to: 7.1
Requires PHP: 8.1
Stable tag: 0.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Records content and configuration changes made on a staging site and replays them on live as a patch. Never merges databases.

== Description ==

StagePatch runs on both sites. On staging it records what you change: pages and posts, their meta and terms, menus, widgets, theme mods, allowlisted options and media. On live it validates the patch, shows a dry run with conflicts, applies with a rollback snapshot, and can undo.

It never touches orders, customers, users, sessions, cron or transients. WooCommerce orders in HPOS or legacy storage are excluded by construction, and product stock, price and sales meta are never recorded even when products are opted in.

* Patch, not merge. The same plugin runs as recorder (staging) or applier (live).
* Stable identities: objects that existed when staging was cloned share IDs; new objects get a uuid and are mapped to their live ID on apply.
* References inside content (block attributes, galleries, captions, menu targets, thumbnails, theme logos) are rewritten to live IDs.
* Every apply is preceded by a dry run with a three-column conflict view, and a rollback snapshot of every touched object.
* Move the signed zip by hand (StagePatch Pro pushes it over REST).
* WP-CLI: `wp stagepatch batches|export|import|apply|rollback`.

== StagePatch Pro ==

The free plugin is complete: record, review, export a signed patch, import it on live with a dry run, apply with a rollback snapshot, undo, all from the admin screens or WP-CLI. StagePatch Pro adds pushing a batch straight from staging to live over REST (Application Passwords plus signed requests, chunked uploads) with live's dry run shown inline. It is a separate add-on sold at https://github.com/hexcorpIO/Stagepatch.

== Installation ==

1. Install and activate on both sites.
2. Set the same shared secret (16+ characters) under StagePatch → Settings on both sites, or define `STAGEPATCH_SECRET` in wp-config.php.
3. On live, set the mode to Applier. On a fresh clone of live, set staging to Recorder: this captures the baseline.
4. Work on staging. Review StagePatch → Changes, create a batch, export it (`wp stagepatch export`), then upload the zip under StagePatch → Import on live, review the dry run and apply.

== Frequently Asked Questions ==

= Does it support multisite? =

No. StagePatch is single-site only and refuses network activation. Activate it on the individual staging and live sites.

= I use nginx. Are uploaded bundles protected? =

Bundles and rollback backups live under `wp-content/uploads/stagepatch/` with unguessable names, plus `.htaccess` and `web.config` files that Apache and IIS honour. nginx ignores those files, so add a rule such as `location ~* /wp-content/uploads/stagepatch/ { deny all; }`.

= A large push times out. What now? =

Live keeps working after the connection drops and finishes the apply; staging shows an error because it stopped waiting. Open StagePatch → Import on live, or run `wp stagepatch batches`, to see the batch as applied. A second push is refused as already applied, so nothing is written twice. For very large batches, apply the exported zip on live with `wp stagepatch apply` instead of pushing.

= Which PHP extensions are needed? =

The zip extension (ZipArchive) on both sites, and GD or Imagick on live to regenerate image sizes.

= Does it merge databases? =

No. It records individual changes and replays them. Live data it does not know about is left alone.

= What happens when live changed the same page? =

The dry run flags a conflict and shows staging before, staging after and live now, field by field. You choose per conflict: take staging, keep live or skip.

= Can I undo? =

Yes. Every apply stores a snapshot of each touched object. Rollback restores them, and a failed apply rolls back on its own.

== Changelog ==

= 0.1.0 =
* Initial release.
