Title: Bauhaus File Cleanup for Tainacan
Author: bauhaustech
Published: <strong>July 7, 2026</strong>
Last modified: July 7, 2026

---

Search plugins

![](https://ps.w.org/bauhaus-file-cleanup-for-tainacan/assets/banner-772x250.png?
rev=3599035)

![](https://ps.w.org/bauhaus-file-cleanup-for-tainacan/assets/icon.svg?rev=3599044)

# Bauhaus File Cleanup for Tainacan

 By [bauhaustech](https://profiles.wordpress.org/bauhaustech/)

[Download](https://downloads.wordpress.org/plugin/bauhaus-file-cleanup-for-tainacan.1.0.0.zip)

 * [Details](https://wordpress.org/plugins/bauhaus-file-cleanup-for-tainacan/#description)
 * [Reviews](https://wordpress.org/plugins/bauhaus-file-cleanup-for-tainacan/#reviews)
 *  [Installation](https://wordpress.org/plugins/bauhaus-file-cleanup-for-tainacan/#installation)
 * [Development](https://wordpress.org/plugins/bauhaus-file-cleanup-for-tainacan/#developers)

 [Support](https://wordpress.org/support/plugin/bauhaus-file-cleanup-for-tainacan/)

## Description

Tainacan does not reliably remove uploaded files from disk when items are permanently
deleted. In particular, files of **private items** — which Tainacan stores in prefixed`
_x_<item_id>` folders — are left orphaned in the uploads directory, slowly bloating
disk usage. Tainacan’s own code documents this as an unresolved TODO (`Private_Files::
rename_item_and_collection_folder_path` returns early on permanent deletion).

This add-on fixes that. While it is active, permanently deleting an item always 
removes its files by default. You can disable this behaviour from **Settings  Bauhaus
File Cleanup for Tainacan** if you need to temporarily keep files while the plugin
stays active.

This is an independent add-on developed by Bauhaus Tech. It is **not affiliated 
with, endorsed by, or part of** the Tainacan project.

It works by hooking WordPress’ `before_delete_post`, which fires on every permanent
deletion regardless of where it was triggered:

 * the Tainacan admin trash (REST API);
 * the bulk-edit “delete” background process;
 * the WordPress admin “Empty Trash”;
 * WP-CLI (`wp tainacan ...` garbage collector);
 * any other `wp_delete_post( $id, true )` call.

For each deleted Tainacan item it:

 1. Deletes the remaining attachment posts (document, child attachments, thumbnail)
    forcing real file removal (bypassing the media trash).
 2. Removes the item’s dedicated upload folder recursively — covering WordPress-generated
    derivative image sizes and the private `_x_` folders — by reconstructing the path
    from the item and collection IDs instead of trusting the (often out-of-sync) attachment
    metadata.

When a whole collection is permanently deleted, its entire `tainacan-items/<collection_id
>` folder is removed too.

### Important notes

 * This is **destructive and irreversible**: files are deleted from disk, not sent
   to a trash. This is intentional — it is what the plugin exists to do.
 * Each Tainacan item owns an isolated upload folder, so deleting it does not affect
   other items. The plugin does **not** scan metadata for attachments shared across
   items; if you reuse a single attachment across multiple items, deleting one item
   may remove that shared file.
 * Sending an item to the trash does nothing — cleanup only happens on **permanent**
   deletion.

## Installation

 1. Upload the `bauhaus-file-cleanup-for-tainacan` folder to `/wp-content/plugins/`,
    or install the ZIP via **Plugins  Add New  Upload Plugin**.
 2. Activate the plugin through the “Plugins” menu in WordPress.
 3. Ensure Tainacan is installed and active.
 4. Visit **Settings  Bauhaus File Cleanup for Tainacan** to toggle the behaviour on
    or off. The plugin defaults to enabled.

## FAQ

### Does it delete files when I just trash an item?

No. It only acts on permanent deletion (emptying the trash / “delete permanently”).

### Can I keep the files?

Visit **Settings  Bauhaus File Cleanup for Tainacan** and uncheck the toggle. The
plugin stays active but stops removing files. You can also deactivate the plugin
entirely — with it inactive, WordPress/Tainacan behave as before.

## Reviews

There are no reviews for this plugin.

## Contributors & Developers

“Bauhaus File Cleanup for Tainacan” is open source software. The following people
have contributed to this plugin.

Contributors

 *   [ bauhaustech ](https://profiles.wordpress.org/bauhaustech/)
 *   [ Fred Marvila ](https://profiles.wordpress.org/marvila/)

[Translate “Bauhaus File Cleanup for Tainacan” into your language.](https://translate.wordpress.org/projects/wp-plugins/bauhaus-file-cleanup-for-tainacan)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/bauhaus-file-cleanup-for-tainacan/),
check out the [SVN repository](https://plugins.svn.wordpress.org/bauhaus-file-cleanup-for-tainacan/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/bauhaus-file-cleanup-for-tainacan/)
by [RSS](https://plugins.trac.wordpress.org/log/bauhaus-file-cleanup-for-tainacan/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.0.0

 * Initial release. Fixes orphaned files left by Tainacan on permanent deletion —
   including the private items “_x_” folders. Includes a settings page under Settings
   Bauhaus File Cleanup for Tainacan with an enable/disable toggle (defaults to 
   enabled), path traversal protection, and recursive folder cleanup of all derivative
   sizes.

## Meta

 *  Version **1.0.0**
 *  Last updated **12 hours ago**
 *  Active installations **Fewer than 10**
 *  WordPress version ** 5.5 or higher **
 *  Tested up to **7.0**
 *  PHP version ** 7.4 or higher **
 * Tags
 * [attachments](https://wordpress.org/plugins/tags/attachments/)[cleanup](https://wordpress.org/plugins/tags/cleanup/)
   [disk space](https://wordpress.org/plugins/tags/disk-space/)[tainacan](https://wordpress.org/plugins/tags/tainacan/)
   [uploads](https://wordpress.org/plugins/tags/uploads/)
 *  [Advanced View](https://wordpress.org/plugins/bauhaus-file-cleanup-for-tainacan/advanced/)

## Ratings

No reviews have been submitted yet.

[Your review](https://wordpress.org/support/plugin/bauhaus-file-cleanup-for-tainacan/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/bauhaus-file-cleanup-for-tainacan/reviews/)

## Contributors

 *   [ bauhaustech ](https://profiles.wordpress.org/bauhaustech/)
 *   [ Fred Marvila ](https://profiles.wordpress.org/marvila/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/bauhaus-file-cleanup-for-tainacan/)