=== Altaris Cleaner ===
Contributors: altaris
Tags: database cleaner, db cleanup, orphan data, plugin remnants, database optimization
Requires at least: 5.5
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Clean up orphaned database records left behind by removed plugins. Safe, fast and free.

== Description ==

**Altaris Cleaner** is a free WordPress plugin that safely detects and removes unnecessary database leftovers.

When you remove a plugin, WordPress only deletes the files. The database records — options, post meta, and custom tables — remain behind. Altaris Cleaner finds them and cleans them up.

= Features =

* **Orphan Post Meta Scanner** — Finds meta records belonging to deleted posts
* **Orphan Options Scanner** — Detects wp_options records not belonging to any active plugin
* **Transient Cleaner** — Removes expired transients with one click
* **Revision Cleaner** — Lists and removes old post revisions (30/60/90 days)
* **Orphan Table Scanner** — Detects custom tables not belonging to any active plugin
* **Snapshot-Based Confidence System** — Rates each orphan table as high/medium/low risk using snapshot comparison
* **Code Analysis Engine** — Scans PHP source code to extract DB fingerprints and compare with actual database
* **Theme Remnant Scanner** — Detects leftover options from removed or switched themes
* **Custom Prefix Scanner** — Scan the database for any user-defined option prefix
* **Reverse Scan** — Finds DB records that exist but are not referenced in any code
* **Clean Uninstall** — Removes DB leftovers when uninstalling a plugin
* **SQL Export** — Download a .sql backup before deleting any records or tables
* **Snapshot System** — Tracks plugin changes to detect leftover data
* **Simulation Mode** — Preview what would be deleted before actually deleting
* **Undo** — Restore deleted options within 24 hours
* **Action Log** — Every cleanup action is logged with timestamp and user

= Code Analysis Engine (New in 1.0.0) =

The Code Analysis engine is a unique feature not found in any other WordPress plugin. It scans theme and plugin PHP files to extract database fingerprints — every option, post type, post meta, user meta, transient, widget, custom table, shortcode, cron job, and taxonomy registered in the code.

It then compares these fingerprints with the actual database to identify:

* **In use** — Key exists in both code and database
* **Not in use** — Key exists in database but not in code (remnant)
* **Removed sources** — Theme/plugin was deleted but its fingerprint is saved, so remnants can still be detected

The engine supports 13 scan categories and detects dynamic keys like `get_option("prefix_{$id}")`.

= How the Snapshot System Works =

When Altaris Cleaner is activated, it takes a snapshot of all wp_options keys and database tables. When a plugin is later removed, the snapshot comparison reveals exactly which options and tables were left behind.

The Orphan Table Scanner uses this data to show a confidence badge for each table:

* **Snapshot match (red)** — Table existed at snapshot time; its plugin may have been removed
* **New table (yellow)** — Table appeared after the snapshot; origin unknown
* **Unknown (blue)** — No snapshot available or no prefix match; inspect carefully

= Security =

* WP core options and tables are never touched
* Every action requires nonce + capability check
* Mandatory preview before any deletion
* SQL backup option before every delete operation
* WordPress-style modal confirmation dialogs
* Batch processing (max 1000 records per request)
* realpath() protection against path traversal

= Supported Languages =

Turkish (default), English, German, French, Spanish

== Installation ==

1. Download `altaris-cleaner.zip`
2. Go to WordPress Admin → Plugins → Add New → Upload Plugin
3. Select the ZIP file and upload
4. Click "Activate"
5. Find **Altaris Cleaner** in the left menu

== Frequently Asked Questions ==

= Will this plugin delete my data? =

No. Nothing is deleted without your confirmation. Every action shows a preview and requires approval. You can also download a SQL backup before any deletion.

= Does it touch WP core tables or options? =

Absolutely not. wp_posts, wp_options, wp_users and all core tables/options are protected and never modified. The Code Analysis engine also filters out WP core options automatically.

= Can I undo a deletion? =

For option deletions, yes — you have 24 hours to restore them. For table deletions, we recommend downloading a SQL backup first using the built-in export feature.

= What does the Code Analysis do? =

It scans theme/plugin PHP files and extracts every database key they use. Then it compares with the real database to find records that are no longer referenced in any code — true remnants that can be safely removed.

= What does the Snapshot System do? =

It records the list of all wp_options keys and database tables when the plugin is activated. When you later remove another plugin, the snapshot comparison reveals which records were left behind.

= What does "Clean Uninstall" do? =

WordPress normally only deletes plugin files. The "Clean Uninstall" button also removes the plugin's database options and custom tables, leaving no trace behind.

= Is it safe for large databases? =

Yes. All scan and delete operations run via AJAX with batch processing (1000 records per request), so the page never freezes.

== Screenshots ==

1. Dashboard — quick scan summary
2. Scan page — category selection and results with confidence badges
3. Code Analysis — theme/plugin fingerprinting with used/unused badges
4. Clean Uninstall — preview and confirmation
5. Snapshot page — history and comparison
6. Log page — full action history
7. Settings page

== Changelog ==

= 1.0.0 =
* New: Code Analysis Engine — scans PHP source code to extract DB fingerprints
* New: Reverse Scan — finds DB records not referenced in any code
* New: 13 scan categories (options, post types, taxonomies, post meta, user meta, theme mods, transients, widgets, custom tables, nav menus, shortcodes, cron, settings)
* New: Dynamic key detection (e.g. `get_option("prefix_{$id}")`)
* New: Fingerprint manager — save, compare, and track removed themes/plugins
* New: Status badges (Active / Inactive / Removed) in Code Analysis
* New: Filter buttons (All / In Use / Not In Use) with select-all support
* New: WordPress-style modal confirmation for all delete operations
* New: SQL backup option before deleting (all scan types and Code Analysis)
* New: Remnant export as .sql (options, post meta, transients)
* Improved: WP core option whitelist expanded (widget_media_*, widget_custom_html, etc.)
* Improved: Core options filtered from Code Analysis results automatically
* Fixed: log() method accessibility for cross-class calls

= 0.3.0 =
* Improved: Theme remnant scanner now tracks theme switches automatically
* Improved: Old theme name and removal date shown in scan results
* Improved: Theme prefix detection expanded (hyphenated slugs, DB-verified prefixes)
* New: switch_theme hook saves previous theme info for accurate remnant detection

= 0.2.0 =
* New: Theme remnant scanner — detects leftover options from removed themes
* New: Custom Prefix Scanner — scan wp_options for any user-defined prefix

= 0.1.1 =
* Fixed: Transient scan results were not showing in the list
* Fixed: Orphan table scan results were not showing in the list
* New: Snapshot now records database table list
* New: Orphan table confidence system (high/medium/low)
* New: Confidence badge legend shown in scan results

= 0.1.0 =
* Initial release
* Orphan post meta scanner
* Orphan options scanner
* Transient cleaner
* Revision cleaner
* Orphan table scanner
* Clean Uninstall feature
* SQL export
* Snapshot system
* Simulation mode
* 24-hour undo
* Action log with CSV export
* 5 language support (TR, EN, DE, FR, ES)

== External Services ==

This plugin connects to altaris.com.tr to fetch the Altaris plugin list displayed on the Plugins tab. This request is made only when that admin page is visited. No personal user data is transmitted.

Service provider: Altaris
Website: https://altaris.com.tr
Terms of Use: https://altaris.com.tr/kullanim-kosullari/
Privacy Policy: https://altaris.com.tr/gizlilik-politikasi/

== Upgrade Notice ==

= 1.0.0 =
Major release: Code Analysis Engine with PHP source scanning, reverse scan, WordPress modal confirmations, and SQL backup for all delete operations.

= 0.3.0 =
Smarter theme remnant detection. Tracks theme switches automatically for accurate cleanup.

= 0.1.1 =
Bug fixes for transient and orphan table scanning. Snapshot now tracks database tables. Recommended update.

= 0.1.0 =
Initial stable release.
