=== M7tawa Database Care ===
Contributors: aymanabdullahdev
Tags: database, cleanup, optimize, revisions, transients
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A scan-first WordPress database cleanup and optimization tool with explicit confirmation, safety batching, and conservative cleanup rules.

== Description ==

M7tawa Database Care is a deliberately conservative database maintenance tool for WordPress administrators who want visibility and control before any cleanup happens. Unlike aggressive one-click cleanup tools, it starts with a read-only scan, shows exactly what can be cleaned, requires explicit selection and final confirmation, processes large cleanups in small safety batches, keeps the latest revision for each post, and never auto-deletes unknown plugin tables or unknown wp_options entries. It uses no external service, sends no database data off-site, and is designed to reduce maintenance risk on both small and large WordPress installations.

The plugin is available from Tools > Database Care.

M7tawa Database Care includes:

* Read-only database scan before cleanup.
* Database size and table overview.
* Post revision cleanup while keeping the latest revision for each post.
* Auto-draft cleanup.
* Trashed post and page cleanup.
* Spam and trashed comment cleanup.
* Expired transient cleanup.
* Orphan post, comment, term, and user meta cleanup.
* Orphan taxonomy relationship cleanup.
* oEmbed cache cleanup.
* Table optimization for this site's prefixed tables that report Data_free.
* Last 10 cleanup activity records.
* No automatic deletion of unknown plugin tables or unknown options.
* No external service, tracking, or data transmission.

The scan does not modify database content. Cleanup happens only after an administrator explicitly selects items and confirms the action.

Important: Data_free is a database-engine indicator and does not guarantee that the same amount of disk space will be returned after optimization, particularly with InnoDB.

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/` or install the ZIP from Plugins > Add New > Upload Plugin.
2. Activate M7tawa Database Care.
3. Go to Tools > Database Care.
4. Run a safe scan.
5. Review the results, select only the items you want to clean, and confirm the cleanup.

== Frequently Asked Questions ==

= Does the scan delete anything? =

No. The scan is read-only.

= Does M7tawa Database Care remove tables left by deleted plugins? =

No. Unknown plugin tables and unknown options are never auto-deleted.

= Does the plugin send database information outside my site? =

No. It uses no external service and sends no database information elsewhere.

= Is a backup recommended? =

Yes. A current database backup is recommended before any database cleanup operation.

== Changelog ==
= 1.1.5 =
* Escaped the table name used by the pre-optimization SHOW TABLES LIKE existence check so underscore and percent characters are matched literally.
* No cleanup, batching, revision retention, or optimization behavior changed.

= 1.1.4 =
* Refined direct database reads so WordPress Plugin Check can correctly associate the maintenance-query suppressions with the exact database calls.
* Removed unnecessary nested result mapping around orphan-meta and oEmbed ID queries without changing cleanup behavior.

= 1.1.3 =
* Reworked all prepared database calls so Plugin Check can statically verify them at the call site.
* Corrected direct database-query annotations for intentional maintenance operations.
* No cleanup behavior or safety rules changed.


= 1.1.2 =
* Prepared database queries and identifier placeholders for WordPress coding-standard compatibility.
* Added explicit AJAX nonce and capability checks before request data is processed.
* Improved request sanitization and translation placeholder documentation.
* Documented intentional uncached direct database maintenance queries for Plugin Check.
* No cleanup behavior or batch-processing logic was changed.

= 1.1.1 =
* Fixed batch progress reporting for large cleanup operations.
* Progress now shows the actual cleanup batch number and processed item count instead of staying at 1/1.
* Table optimization progress behavior remains unchanged.

= 1.1.0 =
* Added a final pre-cleanup safety preview with freshly re-checked counts.
* Added small-batch cleanup processing for large datasets.
* Cleanup now stops when a database error is reported instead of continuing blindly.
* Table optimization is processed one table per request, with a MyISAM warning when relevant.
* Added a lightweight backup recommendation instead of creating heavy in-plugin database backups.
* Improved cleanup activity labels for readability.

= 1.0.2 =
* Changed the safety notice to name M7tawa Database Care instead of a version number.
* Styled the safety notice as a prominent red warning box.

= 1.0.1 =
* Changed revision cleanup to keep the latest revision for each post.
* Revision scan count now shows only old revisions eligible for removal.

= 1.0.0 =
* Initial release.
* Added safe read-only scan.
* Added selective cleanup of common WordPress database clutter.
* Added table optimization for eligible site tables.
* Added cleanup activity log.
