=== SpeedX Database Cleaner ===
Contributors: roicecz
Donate link: https://buymeacoffee.com/speedx
Tags: database, database cleanup, revisions, optimization, transients
Requires at least: 6.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.1.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A lightweight, no-bloat WordPress database cleaner. Remove unwanted records manually, with clear statistics and no unnecessary features.

== Description ==

**SpeedX Database Cleaner keeps database cleanup simple.** It does one job: helps you inspect and manually remove selected unwanted records from your WordPress database.

No complicated dashboard. No caching, image optimization, minification, marketing features or background cleanup jobs. The interface is intentionally minimal, practical and focused on the task at hand. The code is designed to stay small and straightforward, without unnecessary dependencies or system overhead.

The plugin does not create its own database tables or persist its settings. Cleanup is initiated manually by an administrator; nothing is scheduled to run automatically.

Before making changes, you can see how many records are eligible for each cleanup operation and an **approximate size of the selected data**. These estimates are not a guarantee of disk space recovered, because database storage and table allocation work differently.

**Important: This plugin does not back up your database. Cleanup permanently deletes data. Always make a verified database backup before running it.** Some WordPress deletion operations also remove related records through the standard WordPress APIs.

**Languages:** English and Czech (cs_CZ). The interface follows your WordPress site language where the translation is available.

== Features ==

* **Revision cleanup:** Keep a configurable number of the latest regular revisions per post (default: 5); autosaves are excluded.
* **Old auto-drafts:** Remove automatic drafts older than seven days, leaving recent drafts untouched.
* **Spam comments:** Permanently delete comments marked as spam.
* **Trashed comments:** Permanently delete comments in the trash.
* **Unapproved comments:** Optionally remove comments awaiting approval.
* **Expired transients:** Remove expired regular WordPress transients.
* **Trashed posts and pages:** Optionally delete standard posts and pages in the trash. Attachments and custom post types are excluded from direct selection.
* **Clear statistics:** Display eligible record counts and approximate data sizes before cleanup.
* **Refresh button:** Recalculate statistics after changing the number of revisions to keep, without starting cleanup.
* **Manual control:** Choose the cleanup categories and explicitly confirm that you have made a backup.
* **On-screen results:** See a summary after cleanup, with optional logging to the WordPress debug log when enabled.

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/speedx-database-cleaner/` or install it through the WordPress Plugins screen.
2. Activate **SpeedX Database Cleaner**.
3. Open **Tools > SpeedX Database Cleaner** in the WordPress administration area.
4. Review the statistics, select the cleanup categories and set how many revisions to keep.
5. **Back up your database before proceeding.** Confirm the warning and run the selected cleanup operations.

== Frequently Asked Questions ==

= Does the plugin create a database backup? =

**No. Absolutely not.** SpeedX Database Cleaner does not create, store or download database backups. We strongly recommend creating and verifying a complete database backup before every cleanup. Use your hosting backup tools or a dedicated backup solution.

= Does the plugin make irreversible changes to the database? =

**Yes.** The plugin permanently deletes selected database records. These operations cannot be undone by the plugin. WordPress deletion APIs may also remove related metadata, comments and revisions. Restore from your backup if you need to recover deleted data.

= Has the plugin been tested? =

**Yes.** SpeedX Database Cleaner has undergone more than four months of testing on different WordPress websites and has evolved substantially during that period. As with any database maintenance tool, we still recommend testing on a staging site and making a backup before using it on a live website.

= Does the plugin run automatically or store settings? =

No. Cleanup is manual. The plugin does not schedule cleanup jobs, create custom database tables or save its configuration between visits. The interface deliberately stays simple and functional.

= What does the estimated data size mean? =

It is an approximation based on the data eligible for cleanup, not a measurement of the disk space that will actually be released. Deleting records does not necessarily reduce the physical size of database files.

= How many revisions does the plugin keep? =

By default, it keeps the five most recent regular revisions for each post. You can change that number before cleanup. Autosaves are excluded from revision cleanup.

= What happens to recent automatic drafts? =

Automatic drafts newer than seven days are not selected for cleanup, helping protect work in progress.

= What does "Trashed posts and pages" delete? =

This option is unchecked by default. It permanently deletes only standard WordPress posts and pages with the trash status. Counts, estimated sizes, selection and the final check before deletion use the same status and post type criteria.

Attachments, custom post types and other content types are excluded from this operation's direct selection. Standard WordPress deletion hooks may still remove related data; this is normal WordPress API behavior.

= Which languages are available? =

English and Czech (cs_CZ).

== Screenshots ==

1. The minimal database cleanup screen, showing eligible record counts, estimated data sizes, revision retention and manual cleanup controls.

== Changelog ==

= 0.1.8 =
* Added: "Go clean" link to the plugin action links in the WordPress Plugins list for quick access to the database cleaner.

= 0.1.7 =
* Fixed: Derive transient value names by removing only the leading timeout prefix. Recheck expiration, delete values before timeouts through the WordPress options API, and count only completed cleanup operations.
* Improved: Verify the action nonce before processing form settings and recheck permissions and the cleanup nonce at the cleanup entry point. Rendering and cleanup receive validated form values.
* Improved: Restrict cleanup helpers to supported post and comment statuses, prepare complete post queries at execution, and recheck comment status before permanent deletion.

= 0.1.6 =
* Added: English source strings and complete Czech translations for the administration interface, messages, cleanup results and plugin description.
* Improved: The revision retention sentence supports plural forms and keeps its input field inside one translatable sentence.
* Updated: Czech PO/MO catalogs and the POT template, with source references and translator notes. Cleanup behavior is unchanged.

= 0.1.5 =
* Changed: Rename the trash category to "Trashed posts and pages" and restrict its statistics, selection and pre-deletion checks to the post and page types with the trash status.
* Clarified: Attachments and custom post types are excluded from direct selection, while WordPress deletion hooks may remove related data. The option remains unchecked by default.

= 0.1.4 =
* Added: A separate Update action refreshes statistics and preserves selected cleanup options without requiring backup confirmation or running cleanup.
* Fixed: Validate the revision retention count on the server so invalid input cannot be interpreted as zero or authorize cleanup.
* Improved: Revision statistics use database aggregates instead of loading all revision IDs into PHP. Comment statistics use one grouped query; expired transient statistics use one query for both count and size.
* No database cache, settings, browser storage or cookies are added.

= 0.1.3 =
* Changed: Prefix the main class with SPX4DBC_ and plugin form fields and nonce identifiers with spx4dbc_ to reduce naming conflicts.

= 0.1.2 =
* Fixed: Only remove automatic drafts older than seven days, using the same age limit for statistics and cleanup.
* Fixed: Exclude autosaves from revision statistics and cleanup, and retain the selected number of latest regular revisions per post.
* Fixed: Recheck record eligibility and retained revisions before deletion, and use the WordPress revision deletion API.

= 0.1.1 =
* Fixed: Escape the transient timeout prefix in statistics and cleanup queries to prevent matching unrelated database options.

= 0.1.0 =
* Initial release.

== Upgrade Notice ==

= 0.1.7 =
Hardens expired transient cleanup, form processing and pre-deletion checks. Cleanup remains manual and creates no persistent settings or statistics cache.

= 0.1.6 =
The interface now uses English source strings and a complete bundled Czech translation selected through the WordPress language settings.

= 0.1.5 =
Trash cleanup now directly selects only standard WordPress posts and pages. Attachments and custom post types are excluded from direct selection.

= 0.1.4 =
Adds a safe statistics refresh button and reduces PHP memory use when calculating revision statistics. Reload an already open cleaner page before submitting its form.

= 0.1.3 =
Standardizes plugin class, form field and nonce names. Reload an already open cleaner page before submitting its form.

= 0.1.2 =
Protects recent automatic drafts and autosaves, and rechecks records before permanent deletion.

= 0.1.1 =
Fixes matching of expired transient option names during database cleanup.
