=== WebProCMS Installer ===
Contributors: webprocms
Tags: webprocms, installer, migration
Requires at least: 5.8
Requires PHP: 8.3
Stable tag: 1.3.0
License: MIT

Installs WebProCMS over this WordPress site — no SSH, no git, no deploy keys. Reuses this site's database.

== Description ==

This plugin turns a RunCloud one-click WordPress install into a WebProCMS install. It downloads the
WebProCMS build from webprocms.com (no license key required — a key is optional), places the files next to
your existing `public/` folder, reuses your WordPress database credentials, then switches the site over.
WordPress is backed up first and can be restored with one click. A free webprocms.com account gives you a
key that activates saving + updates after install; you can add it now or later.

It is intended to be used once and then removed.

== Requirements ==

* RunCloud web app where WordPress was installed INTO a folder named `public` (web app Public Path = /public).
* The web user must be able to write to the webapp root (one level above `public/`). RunCloud's default setup satisfies this.
* PHP 8.3+ (8.4 recommended) with ~512M memory for WebProCMS itself. The installer refuses to run on older PHP; the WebProCMS setup wizard (which opens after the files are installed) checks the remaining host settings and walks you through any changes.
* A WebProCMS license key is OPTIONAL — install is keyless; a key (free or paid) activates saving + updates.

== How it works ==

1. Reads DB_HOST / DB_NAME / DB_USER / DB_PASSWORD from wp-config.php.
2. Asks webprocms.com for the current build's download URL + checksum (sending your key only if you entered one).
3. Downloads the build and verifies its sha256 before placing anything.
4. Extracts it: non-public files go to the webapp root; the `public/` folder becomes `public_laravel/`.
5. Writes storage/wpcms-prefill.json with your DB credentials (and license key, if provided), outside the web root.
6. Renames `public` (WordPress) → `_wp_backup`, then `public_laravel` → `public`.
7. You open your domain; WebProCMS's setup wizard appears with the DB fields (and key, if provided) already filled in.

== Restore / cleanup ==

* If the wizard fails: visit /wpcms-restore.php?token=... (link shown before and after the swap) — a
  confirmation page with one button that brings WordPress back. Nothing is deleted by a restore.
* After WebProCMS works: the wizard's success screen links to /wpcms-cleanup.php?token=..., a confirmation
  page that removes the WordPress backup files and can optionally DROP the old WordPress database tables.
  Only the WordPress tables captured before WebProCMS migrated are dropped; WebProCMS tables are never touched.

== Changelog ==

= 1.3.0 =
* Provider preconfiguration: a fleet manager's "Download installer" button now bakes the license key
  (and, for agency fleets, the fleet reporting endpoint + key + enroll token) into the downloaded copy.
  Installing with a preconfigured copy needs zero fields filled in, and the new site auto-enrolls in its
  provider's managed backup scheduling on first check-in. The stock plugin is unchanged — the license
  field appears exactly as before.

= 1.2.1 =
* SAFETY: the WordPress table snapshot now only captures tables carrying this site's WP table prefix.
  Previously, retrying the install after a failed setup-wizard run could snapshot the (unprefixed)
  WebProCMS tables the failed run left behind — and the cleanup page would then offer to drop them.
  The cleanup script's live-detection fallback honors custom prefixes via the recorded prefix.
* The restore helper now shows a confirmation page on GET and only restores on POST, so link-preview
  bots and prefetchers hitting the URL can never flip the site back to WordPress by accident.
* Preflight refuses PHP older than 8.3 (Laravel's floor) BEFORE anything is swapped; the plugin
  header now also declares Requires PHP 8.3 so activation is blocked on older servers.
* The restore/cleanup helper writes are verified — the install aborts before the swap if the safety
  net can't be written, instead of advertising a restore URL that would 404.
* Socket-based WordPress DB connections (DB_HOST "localhost:/path/to/mysql.sock") are carried into
  the wizard prefill as db_socket and written to DB_SOCKET in .env.
* A 401/403 from the license server now says the key wasn't recognized instead of "try again".
* The forced "direct" filesystem method is now scoped to the installer's own AJAX steps instead of
  hijacking filesystem detection for every plugin/core update while the plugin is active.
* Never lower a PHP memory limit that is already configured above 512M (or unlimited).
* Refuse to run on multisite networks (the swap would take down every subsite).
* The WordPress restore link is now shown in the "place" step — before the swap — so it survives a
  lost final response.
* Guard against writing the restore/cleanup helpers with an empty security token.
* The restore script no longer fails when public_laravel_failed/ already exists from an earlier
  attempt (it picks a timestamped name instead; cleanup sweeps all variants).
* Cleanup page: "Drop the WordPress database tables" now defaults to unchecked.
* Added `Update URI: false` so wordpress.org can never shadow-update this private plugin.

= 1.2.0 =
* Keyless, frictionless install: a license key is now OPTIONAL. The plugin downloads the free build from
  webprocms.com without a key (sha256-verified); a key, if entered, is sent as a Bearer and pre-fills
  CMS_LICENSE_KEY. Activation (saving + updates) happens later with a free or paid key.

= 1.1.0 =
* Download the build from webprocms.com (sha256-verified) instead of the public GitHub archive. Adds a
  license-key field to the installer page.

= 1.0.0 =
* Initial release.
