=== StageBridge ===
Contributors:      emunot
Author:            Daniel Emunot
Tags:              staging, clone, backup, deployment, development
Requires at least: 6.2
Tested up to:      7.0
Requires PHP:      7.4
Stable tag:        1.6.28
License:           GPL-2.0+
License URI:       https://www.gnu.org/licenses/gpl-2.0.html

WordPress staging workflow manager for cloning, syncing, pushing, restoring, and backing up sites from the dashboard.

== Description ==

StageBridge gives you a complete staging workflow without leaving WordPress.

**Core Features**

* **Clone** - Create a staging copy of your production site in a configurable subfolder, such as /staging/, or on a staging subdomain such as staging.example.com.
* **Sync** - Pull current production files and database changes into staging.
* **Push** - Push staging changes back to production with safe conflict protection by default.
* **Force overwrite** - Optional push mode for cases where staging should intentionally replace production changes.
* **Backups** - Create full, database-only, or files-only backups manually or on a schedule.
* **Restore** - Restore from saved backups when you need to roll back.

**Additional Features**

* Incremental file copying for clone, sync, and push operations.
* Conflict-aware push protection for production files and common WordPress content tables.
* Compressed file backups to reduce inode usage.
* Automatic full safety backups before sync and push, with a per-operation checkbox to skip them when appropriate.
* Subfolder or subdomain staging URL modes.
* Staging admin bar indicator and frontend staging banner.
* Same-tab switch buttons to reduce accidental editing in the wrong environment.
* Search/replace for URLs and paths with serialized data support.
* Password-protect staging with .htaccess / .htpasswd when supported by the server.
* robots.txt handling for staging environments.
* Email notifications for clone, sync, push, and backup events.
* Live activity logs and persistent completion modals for long-running operations.
* Configurable file exclusions for cache, backup, archive, and log files.
* Automatic retries for temporary server errors.
* Clean uninstall that removes plugin options and custom plugin tables.

StageBridge is intended for site owners, maintainers, and developers who need a practical staging workflow from inside WordPress.

== Requirements ==

* WordPress 5.9 or higher
* PHP 7.4 or higher
* ZipArchive PHP extension for file and full backups
* mod_rewrite for optional staging password protection on Apache-compatible servers
* Sufficient disk space for staging copies and backups

== Installation ==

1. Upload the `stagebridge` folder to the `/wp-content/plugins/` directory, or install the ZIP through **Plugins > Add New > Upload Plugin**.
2. Activate StageBridge through the **Plugins** menu in WordPress.
3. Go to **StageBridge** in the admin sidebar.
4. Review the settings and exclusions.
5. Click **Clone to Staging** to create your first staging environment.

== Frequently Asked Questions ==

= Does StageBridge push every production table and file by default? =

No. Sync and push operations compare files and database tables so unchanged items can be skipped. Push is safe by default and tries to preserve production changes made since the last clone, sync, or push.

= Can I force staging to overwrite production? =

Yes. Push includes an explicit force overwrite option with a warning. Use it only when you are sure staging should replace matching production files and database data.

= Are backups compressed? =

Yes. File and full backups store site files in a ZIP archive when the PHP ZipArchive extension is available.

= Does the plugin protect staging from search engines? =

StageBridge writes staging support files, including robots handling, so staging copies are discouraged from being indexed.

= Can I change the staging folder after staging has been created? =

The staging folder and URL type settings are locked while a staging environment exists. Delete staging first if you need to recreate it in a different folder or switch between subfolder and subdomain staging.

= Can StageBridge create DNS records or hosting subdomains? =

No. If you choose subdomain staging, create the subdomain in your hosting panel first and point its document root to the staging folder configured in StageBridge.

= Will this work on every host? =

StageBridge is designed for standard WordPress hosting, but very large sites can still be limited by hosting CPU, disk, memory, request timeout, or firewall rules. The plugin includes retry and pacing safeguards, but reliable backups are still recommended before major operations.

== Screenshots ==

1. Dashboard showing production and staging environments.
2. Clone, sync, and push progress modal with live operation logs.
3. Push confirmation modal with safe push and force overwrite options.
4. Backup list with restore and bulk delete actions.
5. Settings screen with exclusions, retry attempts, and backup options.

== Privacy ==

StageBridge runs locally inside your WordPress installation. It does not send site data to an external service.

The plugin stores settings, logs, backup metadata, operation progress, and staging metadata in the WordPress database. Backup archives and temporary job files are stored on your server under wp-content/uploads/stagebridge/. Email notifications are sent through your WordPress site's configured mail system.

== Upgrade Notice ==

= 1.6.28 =
Tightens review-readiness for output escaping and runtime warning handling.

= 1.6.27 =
Uses WordPress safe HTTP requests for generated-asset warmups.

= 1.6.26 =
Tightens WordPress.org review hardening for root detection, uninstall SQL, and custom table creation.

= 1.6.25 =
Routes StageBridge local reads, writes, and directory removals through the WordPress filesystem API.

= 1.6.24 =
Avoids uploads-derived root guessing when detecting the site root for review compatibility.

= 1.6.23 =
Addresses WordPress.org review feedback for path detection, filesystem writes, and prepared SQL identifiers.

= 1.6.22 =
Fixes the main Backups page so saved backups are listed correctly.

= 1.6.21 =
Ensures completed operation modals always show the main progress bar at 100%.

= 1.6.20 =
Makes progress pills smaller and uses green filled progress within each pill.

= 1.6.19 =
Softens progress modal typography and removes the visible focus rectangle from the log toggle.

= 1.6.18 =
Tightens progress modal layout and makes the main progress bar reflect overall operation progress.

= 1.6.17 =
Refines operation modals with compact phase progress pills and collapsed live logs.

= 1.6.16 =
Adds the final generated-file safety pass to sync as well as clone.

= 1.6.15 =
Adds a final generated-file check after staging config is written, catching frontend assets created during clone finalization.

= 1.6.14 =
Corrects the clone progress checklist count after adding the reconciliation step.

= 1.6.13 =
Adds final clone file reconciliation so late-generated included files are copied before staging is finalized.

= 1.6.12 =
Adds authenticated file diagnostics to trace why included files may be missing from staging.

= 1.6.11 =
Reverted before release in favor of diagnostic tracing.

= 1.6.10 =
Initial missing generated asset repair attempt, superseded by diagnostic tracing.

= 1.6.9 =
Adds default-on safety backup checkboxes for sync and push.

= 1.6.8 =
Review hardening for large-site file baseline storage.

= 1.6.7 =
Review hardening for WordPress.org compatibility checks.

== Changelog ==

= 1.6.28 =
* Escaped remaining dashboard output values that were safe but not scanner-friendly.
* Replaced direct unserialize warning suppression with a small guarded unserialize helper.

= 1.6.27 =
* Replaced generated-asset warmup requests with wp_safe_remote_get(), safe URL sanitization, and default SSL verification.

= 1.6.26 =
* Removed the custom server-root fallback and kept site-root detection on WordPress-native get_home_path().
* Converted uninstall cleanup and custom table creation to validated/prepared SQL identifiers.
* Fixed a staging diagnostic query to use a prepared table identifier.

= 1.6.25 =
* Removed remaining raw local file read fallback from StageBridge helpers.
* Replaced the remaining raw directory removal path with WordPress filesystem API removal.
* Centralized local file writes through the WordPress filesystem API.

= 1.6.24 =
* Removed uploads-derived site-root guessing and routed root detection through WordPress-native helpers.
* Loaded the WordPress filesystem API from the detected site root.

= 1.6.23 =
* Replaced uploads-path root inference with WordPress-native root detection.
* Routed file copy/timestamp preservation through the WordPress filesystem API with destination-root guards.
* Converted dynamic SQL identifiers to wpdb::prepare() %i placeholders and raised the minimum WordPress version to 6.2.

= 1.6.22 =
* Fixed the Backups page variable mismatch that could make existing backups appear as empty.

= 1.6.21 =
* Fixed completed operation modals sometimes showing a partially-filled main progress bar despite reporting 100%.

= 1.6.20 =
* Reduced phase pill text to 9px.
* Changed phase pill progress fills to green.

= 1.6.19 =
* Reduced progress modal text sizes for a cleaner, denser layout.
* Removed the visible focus rectangle from the live log toggle.

= 1.6.18 =
* Moved the main operation progress bar above the phase pills.
* Added the current step subtitle to the progress modal header.
* Tightened phase pill sizing and made the main percentage reflect overall phase completion.

= 1.6.17 =
* Refined operation progress modals with compact filled phase pills.
* Collapsed live activity logs by default while keeping log lines available on demand.

= 1.6.16 =
* Added a final generated-file safety pass to sync, warming production/staging once and copying only missing included files after staging config is written.
* Updated the sync progress checklist to show the generated-file check and metadata steps clearly.

= 1.6.15 =
* Added a final generated-file check after staging config is written, copying only missing files so staging config/runtime files are not overwritten.
* Warmed production and staging front pages once during clone finalization so generated frontend assets can be created before the final missing-file copy.

= 1.6.14 =
* Corrected the clone progress checklist count after adding the file reconciliation step.

= 1.6.13 =
* Added a final clone file reconciliation pass to copy included files that appear or change after the initial clone scan, preventing late-generated frontend assets from being missed.

= 1.6.12 =
* Added authenticated staging file diagnostics for tracing source/staging file existence, exclusion status, baseline presence, and missing-file examples.
* Removed the broad missing-file repair attempt so diagnostics can reveal the actual cause instead of hiding the symptom.

= 1.6.11 =
* Reverted before release in favor of diagnostic tracing.

= 1.6.10 =
* Added an initial generated frontend asset repair pass for sync. Superseded by diagnostic tracing.

= 1.6.9 =
* Added default-enabled safety backup checkboxes to sync and push flows so users can skip pre-operation backups for small repeat operations.
* Clarified sync and push logs when a pre-operation safety backup is skipped by user choice.

= 1.6.8 =
* Moved push file-baseline manifests out of the database option row and into protected files under wp-content/uploads/stagebridge/baselines.
* Kept only compact baseline metadata in the WordPress option to avoid large database payloads on sites with many files.

= 1.6.7 =
* Removed PHP timeout adjustments and aligned the minimum WordPress version with the WordPress APIs used by StageBridge.
* Tightened autologin request sanitization for Plugin Check compatibility.

= 1.6.6 =
* Made URL/path replacement idempotent when the replacement contains the search value, preventing staging paths from being repeatedly expanded during clone.

= 1.6.5 =
* Fixed staging diagnostic setup so the endpoint uses the configured staging path before reading debug information.

= 1.6.4 =
* Fixed remaining StageBridge bootstrap references after renaming the main plugin instance function.
* Removed the old autologin token compatibility alias so public hooks and request parameters consistently use the StageBridge prefix.
* Re-verified unique StageBridge-prefixed functions, classes, constants, options, hooks, and AJAX actions.

= 1.6.3 =
* Reworked runtime path handling to use StageBridge helpers built on WordPress path and uploads directory APIs.
* Replaced legacy .htpasswd SHA-1 staging password hashes with bcrypt hashes.
* Removed dynamic WordPress role option writes during staging auto-login repair.
* Replaced remaining direct local file reads with StageBridge local file helpers or wp_json_file_decode().
* Removed fopen/fwrite/fclose from SQL backup export.
* Centralized local file writes through StageBridge helper functions.
* Added strict SQL identifier validation and quoting for dynamic WordPress table and column queries used by clone, sync, push, backup, and restore.
* Removed private-build migration and data-repair compatibility routines that are not needed before public release.

= 1.6.2 =
* Moved backup archives and manifests to wp-content/uploads/stagebridge/backups instead of storing runtime backup data in the plugin directory.
* Removed the automatic admin_init plugin-code sync routine that copied StageBridge code into the staging plugin folder.
* Confirmed remaining STAGEBRIDGE_PLUGIN_DIR usage is limited to loading static plugin files and admin views.

= 1.6.1 =
* Clone URL replacement now shows the current table name in the progress modal instead of only the table number.
* Clone URL replacement now skips known high-volume operational log, traffic, and security scan tables that do not need staging URL conversion.
* Existing in-progress clone jobs remap their URL replacement table index safely when operational tables are filtered out.

= 1.6.0 =
* Optimized URL and path replacement to select only rows that contain the old URL or path before loading and updating data.
* Sync now limits URL and path replacement to database tables that were actually cloned from production.
* Push now limits URL and path replacement to non-content tables that were safely swapped into production.

= 1.5.0 =
* Added baseline-first smart file planning for push and sync. When a file baseline exists, StageBridge uses size and modified time to find changed files before copying.
* Changed new file baselines to store cheap size/mtime signatures instead of hashing every file during baseline refresh.
* Push now copies only planned changed files when a reliable baseline exists, while still detecting and skipping production file conflicts.
* Sync now copies only planned changed files when a reliable baseline exists and removes stale staging files from the same baseline.
* Smart push now narrows WordPress content-object checks to posts/pages/custom post types changed since the baseline, plus deleted content IDs.
* Custom database tables with a primary key and timestamp column now use candidate row detection before falling back to exact row-signature comparison.

= 1.4.4 =
* Added individual mini progress bars for each checklist step in clone, backup, sync, and push modals.
* Kept the main operation progress bar as the overall progress indicator while each active step now has its own local progress.
* Unified pre-sync and pre-push safety backups with the main StageBridge backup directory so they appear in the backup list.
* Hardened backup-store exclusions so file compare/copy operations skip both current and legacy backup paths.

= 1.4.3 =
* Renamed push and sync file phases to clarify that StageBridge compares files first and only copies changed files.
* Renamed push database phases to reflect smart row/content application rather than whole-table-only pushing.
* Improved push activity reports with checked-file counts, changed-file counts, preserved content, conflicts, and untracked-table skips.

= 1.4.2 =
* Removed optional author website metadata because the previous URL returned a 404 during review.
* Changed author display name to Daniel Emunot.
* Moved clone and backup file-list job payloads out of transients and into protected temporary files under uploads/stagebridge/jobs.

= 1.4.1 =
* Added object-level smart push for WordPress content so pages, posts, and custom post types are compared independently instead of only at table level.
* Content-object push now evaluates each post together with its post meta and term relationships, preserving unrelated production edits while allowing non-conflicting staging edits through.
* Revision and auto-draft rows are ignored during object-level push to avoid noisy conflicts from WordPress autosaves and edit history.
* New row/object conflict baselines are created during clone, sync, and push baseline refreshes. Run a fresh sync after updating to create the new object-level baseline before relying on this protection.

= 1.3.88 =
* Replaced the generated autologin bridge file with a WordPress admin-post endpoint.
* Moved StageBridge backup and autologin storage under the uploads directory.
* Removed filesystem memory-limit overrides and normalized root path handling in flagged file-operation paths.

= 1.3.87 =
* Reset temporary server error retry counters after successful recovered requests across clone, sync, push, backup, restore, and delete operations.

= 1.3.86 =
* Added dynamic root-level exclusions so backups, clone, sync, push, previews, and baselines skip unrelated folders inside the WordPress root.
* Excluded common archive/export files such as ZIP, TAR, GZ, SQL, and WPress files by default.
* Updated file selection summaries to use the same automatic exclusions as operations.

= 1.3.85 =
* Hid the staging folder field when creating a subdomain staging environment.
* Reused the subdomain prefix as the staging document-root folder name internally.

= 1.3.84 =
* Fixed the Create Staging dashboard button so it opens the modal reliably.

= 1.3.83 =
* Replaced the inline first-time staging form with a centered create-staging modal.
* Added a segmented Subfolder/Subdomain toggle for staging creation.

= 1.3.82 =
* Added support for creating staging environments as either a subfolder or a subdomain.
* Added staging URL type and subdomain settings, locked after staging is created.
* Updated clone, sync, push, backups, autologin, and staging metadata handling for subdomain staging URLs.

= 1.3.81 =
* Completed StageBridge slug, function, action, option, class, and asset-prefix refactor.
* Removed optional wp-config repair and debug-writing routines.
* Improved plugin and autologin path resolution.

= 1.3.80 =
* Renamed the public plugin identity to StageBridge.
* Moved staging toolbar CSS to WordPress enqueue APIs.
* Removed inline settings-page JavaScript.
* Sanitized decoded JSON request arrays recursively.

= 1.3.79 =
* Fixed boolean request parsing so unchecked force overwrite stays disabled during push.

= 1.3.78 =
* Removed optional plugin website metadata to satisfy WordPress.org submission requirements.

= 1.3.77 =
* Updated public plugin naming and WordPress.org compatibility metadata.

For older release notes, see changelog.txt in the plugin package.
