=== Factory Reset ===
Contributors: ankitrawat
Tags: reset, factory reset, site reset, clean install, wordpress reset
Requires at least: 6.0
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 2.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Author URI: https://ankitrawat.com
Plugin URI: https://ankitrawat.com/factory-reset-plugin/

Reset a single-site WordPress installation by removing site data and installed extensions.

== Description ==

Factory Reset helps developers and advanced users clean a single-site WordPress installation without reinstalling WordPress.

The reset permanently removes site content, comments, uploaded files, users other than the current administrator, installed plugins other than Factory Reset, non-core database tables, and installed themes other than the active theme and its parent theme.

The active theme is preserved so the installation is not left without a usable theme. WordPress core files, the current administrator account, core database tables, and the site's installation URLs are preserved.

**Important:** This operation is permanent. Always create and verify a backup before using Factory Reset.

== Features ==

- Delete posts, pages, custom post types, attachments, revisions, and related data through WordPress APIs.
- Delete comments.
- Delete all users except the current administrator.
- Remove non-core database tables using WordPress's core table list as the protected set.
- Empty the configured WordPress uploads directory while preserving the directory itself.
- Remove installed plugins except Factory Reset.
- Remove installed themes except the currently active theme.
- Reset selected core site settings to clean defaults.
- Require the administrator to type `RESET` before the operation can run.
- Use WordPress nonces and capability checks for the destructive action.
- Single-site only; multisite installations are refused.

== Installation ==

1. Install and activate Factory Reset from the WordPress Plugins screen.
2. Go to **Tools > Factory Reset**.
3. Read the warning and make a verified backup.
4. Type `RESET` in the confirmation field.
5. Click **Reset Site**.

== Frequently Asked Questions ==

= Is Factory Reset reversible? =

No. The reset permanently deletes data. Restore a verified backup if you need to recover the site.

= Which user is preserved? =

The administrator account that performs the reset is preserved. Other WordPress users are deleted.

= Are WordPress core database tables deleted? =

No. WordPress core tables are explicitly protected. Tables outside WordPress's core table list that use the site's database prefix are removed.

= Are WordPress core files deleted? =

No. The plugin only removes files within the configured uploads directory and installed plugins/themes. WordPress core files are not touched.

= Is the active theme deleted? =

No. The active theme is preserved so the site remains usable after the reset. If it is a child theme, its parent theme is preserved too.

= Does Factory Reset support multisite? =

No. The plugin deliberately refuses to run on multisite installations.

= Does Factory Reset send data anywhere? =

No. The plugin does not make remote requests, collect telemetry, or send usage data.

= Should I use this on a production site? =

Only if you intentionally want to permanently remove the site's data and have a verified backup. The plugin is primarily intended for development, testing, and controlled site resets.

== Changelog ==

= 2.0.0 =
- Updated compatibility metadata for WordPress 7.0.
- Reworked destructive operations to protect WordPress core database tables.
- Added single-site enforcement.
- Added mandatory `RESET` confirmation.
- Improved capability, nonce, input validation, output escaping, and redirect handling.
- Removed hard-coded `wp-content` paths in favor of WordPress directory APIs.
- Fixed plugin self-preservation for both directory and root-level installations.
- Preserved the active theme to avoid leaving the site without a usable theme.
- Improved large-site deletion by processing posts in batches.
- Removed the old custom-folder assumption and now clear the configured uploads directory.
- Added internationalization-ready text domain and translatable admin strings.
- Updated documentation for current WordPress.org plugin requirements.

= 1.3 =
- Preserved the empty themes folder after reset.
- Improved code structure and readability.
- Added a `$preserve_directory` parameter to the `delete_files` method.
- Updated documentation and tested compatibility with WordPress 6.7.

= 1.2 =
- Initial release with basic reset functionality.

== Upgrade Notice ==

= 2.0.0 =
This release contains a major safety and compatibility rewrite. Back up the site before using Factory Reset.

== License ==

This plugin is licensed under the GNU General Public License v2 or later.

== Author ==

Developed by Ankit Rawat.

== Plugin URI ==

For more information, visit the plugin page.
