=== Cokama Database Cleaner ===
Contributors: littlegreenman
Tags: database, cleanup, transients, revisions, orphaned
Requires at least: 6.5
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.2.20
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Finds database clutter, shows a preview, and deletes only what you tick after you confirm a backup.

== Description ==

Deletions are permanent. Take a full database backup through your host or a backup plugin first. The SQL download is an undo file for the rows this clean removes, not a full backup.

Cokama Database Cleaner finds expired transients, orphaned meta, old revisions, leftover auto-drafts, trash and spam. It never deletes anything until you preview it, tick the categories you want, confirm you have a backup, and press Clean.

**Nothing locked, no Pro version.** The full cleaner is in this plugin.

Installing it changes nothing. No category is ticked. There is no OPTIMIZE TABLE, because that locks tables on shared hosting. It does not touch other plugins' custom tables, published content, users, or options other than expired transients.

= What it cleans =

* Expired transients, including site transients on multisite (site transients are network-admin on the main site only)
* Orphaned post meta, comment meta, term relationships and user meta
* Post revisions beyond the last N per post (N defaults to 5)
* Auto-drafts older than 7 days and trashed posts older than the trash window
* Spam comments older than 15 days and trashed comments older than the trash window
* Expired oEmbed cache entries

It also reports autoloaded options size and tables with overhead, with no delete button on those.

More free plugins and help from iWorks Ireland: https://iworks.ie/wp-tools/

== Installation ==

1. Upload the `cokama-database-cleaner` folder to `/wp-content/plugins/`, or install the zip from Plugins → Add New.
2. Activate the plugin.
3. Open **Cokama Tools → Database Cleaner**, review the scan, then tick only what you want to remove.

== Frequently Asked Questions ==

= Does installing it delete anything? =

No. Nothing is selected. The Clean button stays off until you preview a category, tick it, and confirm you have a backup.

= Can I undo a clean? =

The SQL download is an undo file for the rows this clean removes, including related meta and comments, not a full backup. Take a full database backup through your host or a backup plugin first. Attachment files on disk are not in the undo file.

= What if this site uses Redis or Memcached? =

Expired transients are deleted from the options table (and sitemeta on a network) with a direct query, then the matching cache keys are dropped. The clean still finishes when an object cache is in use.

= How does this behave on multisite? =

Each site can clean its own clutter. Orphaned user meta and expired site transients are network-level: only a network administrator on the main site can see or run them. Sub-site admins see a note instead. Uninstall walks every site.

= Nothing locked, no Pro version? =

Yes. There is no paid upgrade inside this plugin.

= Does this plugin contact other sites? =

No. It only reads and, when you ask, writes your own WordPress database.

== Screenshots ==

1. Scan with leftover categories still unticked. Nothing is deleted yet.
2. Preview of sample rows in a category before you tick it.
3. Clean stays off until you confirm a backup and download the SQL undo file.
4. Results after a clean, with a last-20 log.
5. Settings, including the optional weekly clean of low-risk categories.

== Changelog ==

= 1.2.20 =
* Renamed to Cokama Database Cleaner. Improved file path handling and output escaping.

= 1.2.19 =
* Version aligned with the rest of the Cokama suite. No functional changes.

= 1.0.1 =
* Stop the delete loop spinning when an object cache is in use, and count only rows that were actually removed.
* Leave term relationships alone unless the taxonomy is registered and attached to posts (or links).
* Restrict shared users, usermeta and site transients to network admins on the main site.
* Require a preview, a confirm dialog, and stop if more rows appear than you confirmed.
* Write related rows into the SQL undo file and mark the end of the download.
* Load category counts over AJAX, and keep the weekly schedule to low-risk categories.

= 1.0.0 =
* First public release.

== Upgrade Notice ==

= 1.2.20 =
Renamed to Cokama Database Cleaner. Improved file path handling and output escaping.

= 1.2.19 =
Version aligned with the rest of the Cokama suite. No functional changes.

= 1.0.1 =
Safer deletes on cached and multisite installs. Take a full database backup before you clean.

= 1.0.0 =
First public release.
