Linux 软件免费装
Banner图

Bauhaus File Cleanup for Tainacan

开发者 bauhaustech
marvila
更新时间 2026年7月8日 20:45
PHP版本: 7.4 及以上
WordPress版本: 7.0
版权: GPLv2 or later
版权网址: 版权信息

标签

attachments cleanup uploads tainacan disk-space

下载

1.0.0

详情介绍:

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: 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.

安装:

  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.

常见问题:

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.

I deleted a collection. Does this plugin also delete the items that were in it, from the database?

No. Deleting a collection in Tainacan does not delete its items from the database — they become orphaned rows referencing a collection that no longer exists. This plugin removes the collection's upload folder from disk, but it deliberately does not delete any database rows, only files. Cleaning up the orphaned item and attachment posts is Tainacan's own job, and Tainacan already has a tool for it: run wp tainacan garbage-collector --run after deleting a collection.

更新日志:

1.0.0