=== Clearyvo Database Cleanup ===
Contributors: kishollo001
Tags: database, cleanup, autoload, orphaned data, optimize
Requires at least: 6.2
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 0.5.5
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Finds database junk and shows which plugin left it behind. Report first, then clean only what you tick.

== Description ==

Uninstalled plugins rarely clean up after themselves. Their settings stay in the options table, some of them load on every page view, and their tables stay in the database for years. Database Cleanup finds this junk and names the plugin or theme it came from.

**What it checks**

* **Leftovers of removed plugins and themes** – options grouped by the plugin that created them, with size.
* **Autoload bloat** – the largest options that load on every page view, with their owner and status (active, inactive, not installed). WordPress Site Health warns above 800 KB.
* **Orphaned data** – post, comment, term and user meta whose parent no longer exists; term relationships pointing to deleted posts.
* **Clutter** – post revisions, old auto-drafts, spam and trashed comments, trashed posts, expired transients.
* **Tables** – every table of the site with owner, approximate rows, size and overhead.
* **Settings check** – revision limit and trash period.

**How cleaning works**

* Scanning only reads the database.
* Safe items are pre-ticked; items that remove history or trash contents are left for you to decide.
* Posts, revisions and comments are deleted through WordPress core functions, so other plugins are notified and caches stay consistent.
* Cleanup runs in small batches, so it does not time out on large sites.
* For autoload, the plugin only turns autoload off; the value itself is kept.
* Core options are never touched.
* Dropping tables is not offered, because a wrong guess cannot be undone.

Part of the Clearyvo plugin family: focused plugins that each check one part of your site and share one "Site Toolkit" menu with a Site health score. The Site Toolkit plugin has every checker in one plugin, switched on one by one; when it is installed, this plugin's settings and results are shared with it. More at wp-sitechecker.com.

== Installation ==

1. Upload the plugin and activate it.
2. Go to Site Toolkit → Database Cleanup.
3. Click "Scan database", review the results, make a backup, then click "Clean selected".

== Frequently Asked Questions ==

= What is the /wp-json/clearyvo/v1/app/ address? =
A read-only REST route for the Clearyvo Site Inspector Mac app. It shows the Site health score of the Clearyvo plugins to a signed-in administrator (for example with a WordPress Application Password) and changes nothing. It sends nothing anywhere: the app asks, the site answers.

= How does it know which plugin left an option behind? =

It compares option and table names with the prefixes used by installed plugins and themes, and with a built-in list of well-known plugins. Options of themes are matched exactly (theme_mods_). Anything it cannot attribute is shown as "Unknown" and is never pre-ticked.

= Is it safe? =

Make a database backup before cleaning. Only rows you tick are changed, and core options are excluded.

= Does it work on multisite? =

It scans the current site's tables. Orphaned user meta is skipped on multisite because users are shared across the network.

== Free and Pro ==
Everything in this plugin is free. Clearyvo Pro is one add-on for the Pro features of the whole family (image optimisation, AI ALT texts, alerts by email, white-label reports); this checker has none of its own.

== Changelog ==
= 0.5.5 =
* Shared Clearyvo framework 2.3.1: the SEO checker is listed as Clearyvo SEO (formerly Image Alt & SEO) everywhere, whichever Clearyvo plugin loads the framework.

= 0.5.4 =
* Database: every query goes through $wpdb->prepare(), with %i placeholders for table names.

= 0.5.3 =
* New icons: one design for the whole Clearyvo family, with a colour per group of checkers.

= 0.5.2 =
* The other checkers in the shared menu have their new names (SSL Checker, Security Checker, Indexing Checker and the rest).

= 0.5.1 =
* The plugin links point to wp-sitechecker.com again, until the site has moved to clearyvo.com.

= 0.5.0 =
* New: read-only connection for the Clearyvo Site Inspector Mac app (Site health as data, for administrators with an Application Password).

= 0.4.1 =
* Links to the new home of the Clearyvo WordPress plugins: clearyvo.com/wordpress.

= 0.4.0 =
* First release under the Clearyvo name (folder and text domain: clearyvo-database-cleanup). Settings and results of the earlier versions are kept; activating this plugin switches the earlier copy off.
