=== Dev Theme ===
Contributors: galpeaceman, bashari
Tags: development, dev, stage, staging, theme
Requires at least: 4.9
Tested up to: 7.1.4
Stable tag: 2.0.0
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html



== Description ==

= DEV Theme =
Develop a separate copy of your theme files on the existing site, preview it in your browser, and publish it through a verified copy workflow.

Dev Theme provides a responsive dashboard, staged file copying, operation locks, versioned backups and recovery controls. Choose how many previous versions to keep for the main theme and development copy, and restore a specific version from history. Current files are backed up before restoration.

Content, plugins, users and the database remain shared by design. This is theme-file development, not a separate staging site. Code that writes to the database affects the live database.


= How it works? =
Create a development copy in wp-content/themes/dev-theme. Enable it in your profile or set the dev_theme browser cookie to enabled. Cookie previews intentionally work without login; the preview is not private. Child themes keep using their original parent theme.

Publishing first prepares and verifies the new files, backs up the current destination, then swaps the directories. Failed swaps attempt rollback; interrupted swaps are recovered when the next authorized operation acquires the lock. There is a brief interval between directory renames, so coordinate publishing with other file changes and site traffic.

Backups default to 10 versions per destination, configurable from 1 to 50. Legacy -bk folders remain untouched and are not imported. Theme roots and copied content must not contain symbolic links.

Backup storage defaults to a randomized directory under wp-content, with Apache and IIS denial files. On Nginx, configure HTTP denial explicitly for .dev-theme-backups-* and themes/.dev-theme-work-* paths. Prefer a non-public backup directory using the dev_theme_backup_directory filter. Exclude requests with the dev_theme cookie from server and CDN page caches. WP Rocket cookie rules are refreshed when its APIs are available.




== Installation ==
1. Install the Dev Theme 2.0.0 package, including dev-theme.php, readme.txt and the includes and assets folders. PHP 7.4+, WordPress 4.9+ and direct filesystem write access are required.
2. Configure private backup storage or HTTP denial, and cookie exclusions in server/CDN caches as appropriate for your hosting.
3. Go to DEV Theme and choose "Create development copy".
4. Enable Dev Theme in your user profile and save, or set the dev_theme=enabled cookie and reload.
5. Edit and test the development theme files, then choose "Publish to main theme" when ready.
6. Use Version history to restore a saved version, delete a backup or set the retention preference.


== Changelog ==

= 2.0.0 =
* Added a redesigned responsive dashboard with version history, destination filters and confirmation dialogs.
* Added verified, timestamped backups, restoration and deletion. Keep 1-50 backups per destination (default: 10).
* Added staged, hash-verified copying, operation locks, rollback and recovery journals.
* Replaced GET deployment links with permission-checked POST actions and nonces.
* Added checked filesystem operations, path validation and safe symlink deletion; copies containing symlinks are rejected.
* Added fallback to the main theme when the development copy is unavailable.
* Fixed profile checkbox saving, preview detection and WP Engine method checks.
* Added WP Rocket cookie exclusion, configuration refresh and cache clearing after copies and restores.
* Requires PHP 7.4+ and WordPress 4.9+. Direct filesystem write access is required.
* Existing -bk folders are preserved, but are not imported into version history.
* Pre-commit review fixes: Windows junction detection, recovery hash validation, OPcache invalidation, numeric filenames, early preview initialization and stale-form protection.
* Management honors WordPress file-modification policy and requires Super Admin on Multisite. Dedicated backup storage is bound to its themes directory.

= 1.2.0 =
* Added WP Rocket auto cache clearing
* Added option to enable Dev Theme via cookie for non logged in tests

= 1.1.0 =
* Added WP Engine auto cache clearing & auto file permissions resetting

= 1.0.7 =
* Added function dth_is_dev_theme(), returns true if Dev Theme is (actually) working
