{"id":335352,"date":"2026-07-07T12:27:41","date_gmt":"2026-07-07T12:27:41","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/delete-files-for-tainacan\/"},"modified":"2026-07-07T12:27:12","modified_gmt":"2026-07-07T12:27:12","slug":"bauhaus-file-cleanup-for-tainacan","status":"publish","type":"plugin","link":"https:\/\/wordpress.org\/plugins\/bauhaus-file-cleanup-for-tainacan\/","author":23519298,"comment_status":"closed","ping_status":"closed","template":"","meta":{"version":"1.0.0","stable_tag":"1.0.0","tested":"7.0","requires":"5.5","requires_php":"7.4","requires_plugins":null,"header_name":"Bauhaus File Cleanup for Tainacan","header_author":"Bauhaus Tech","header_description":"Removes a Tainacan item's documents, attachments, thumbnail and all generated files from disk when the item (or its collection) is permanently deleted. Solves orphan files left behind in the uploads directory \u2014 including the private items \"_x_\" folders. Independent add-on, not affiliated with the Tainacan project.","assets_banners_color":"fff7d6","last_updated":"2026-07-07 12:27:12","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"https:\/\/github.com\/Bauhaus-Tech\/bauhaus-file-cleanup-for-tainacan","header_author_uri":"https:\/\/bauhaustech.com\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":37,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":{"1.0.0":{"tag":"1.0.0","author":"bauhaustech","date":"2026-07-07 12:27:12"}},"upgrade_notice":[],"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":3599035,"resolution":"128x128","location":"assets","locale":"","width":128,"height":128},"icon-256x256.png":{"filename":"icon-256x256.png","revision":3599035,"resolution":"256x256","location":"assets","locale":"","width":256,"height":256},"icon.svg":{"filename":"icon.svg","revision":3599044,"resolution":false,"location":"assets","locale":false}},"assets_banners":{"banner-1544x500.png":{"filename":"banner-1544x500.png","revision":3599035,"resolution":"1544x500","location":"assets","locale":"","width":1544,"height":500},"banner-772x250.png":{"filename":"banner-772x250.png","revision":3599035,"resolution":"772x250","location":"assets","locale":"","width":772,"height":250}},"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0.0"],"block_files":[],"assets_screenshots":[],"screenshots":[]},"plugin_section":[],"plugin_tags":[1346,3786,17705,225063,85],"plugin_category":[50],"plugin_contributors":[268624,268625],"plugin_business_model":[],"class_list":["post-335352","plugin","type-plugin","status-publish","hentry","plugin_tags-attachments","plugin_tags-cleanup","plugin_tags-disk-space","plugin_tags-tainacan","plugin_tags-uploads","plugin_category-media","plugin_contributors-bauhaustech","plugin_contributors-marvila","plugin_committers-bauhaustech"],"banners":{"banner":"https:\/\/ps.w.org\/bauhaus-file-cleanup-for-tainacan\/assets\/banner-772x250.png?rev=3599035","banner_2x":"https:\/\/ps.w.org\/bauhaus-file-cleanup-for-tainacan\/assets\/banner-1544x500.png?rev=3599035","banner_rtl":false,"banner_2x_rtl":false},"icons":{"svg":"https:\/\/ps.w.org\/bauhaus-file-cleanup-for-tainacan\/assets\/icon.svg?rev=3599044","icon":"https:\/\/ps.w.org\/bauhaus-file-cleanup-for-tainacan\/assets\/icon.svg?rev=3599044","icon_2x":false,"generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Tainacan does not reliably remove uploaded files from disk when items are permanently deleted. In particular, files of <strong>private items<\/strong> \u2014 which Tainacan stores in prefixed <code>_x_&lt;item_id&gt;<\/code> folders \u2014 are left orphaned in the uploads directory, slowly bloating disk usage. Tainacan's own code documents this as an unresolved TODO (<code>Private_Files::rename_item_and_collection_folder_path<\/code> returns early on permanent deletion).<\/p>\n\n<p>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 <strong>Settings \u2192 Bauhaus File Cleanup for Tainacan<\/strong> if you need to temporarily keep files while the plugin stays active.<\/p>\n\n<p>This is an independent add-on developed by Bauhaus Tech. It is <strong>not affiliated with, endorsed by, or part of<\/strong> the Tainacan project.<\/p>\n\n<p>It works by hooking WordPress' <code>before_delete_post<\/code>, which fires on every permanent deletion regardless of where it was triggered:<\/p>\n\n<ul>\n<li>the Tainacan admin trash (REST API);<\/li>\n<li>the bulk-edit \"delete\" background process;<\/li>\n<li>the WordPress admin \"Empty Trash\";<\/li>\n<li>WP-CLI (<code>wp tainacan ...<\/code> garbage collector);<\/li>\n<li>any other <code>wp_delete_post( $id, true )<\/code> call.<\/li>\n<\/ul>\n\n<p>For each deleted Tainacan item it:<\/p>\n\n<ol>\n<li>Deletes the remaining attachment posts (document, child attachments, thumbnail) forcing real file removal (bypassing the media trash).<\/li>\n<li>Removes the item's dedicated upload folder recursively \u2014 covering WordPress-generated derivative image sizes and the private <code>_x_<\/code> folders \u2014 by reconstructing the path from the item and collection IDs instead of trusting the (often out-of-sync) attachment metadata.<\/li>\n<\/ol>\n\n<p>When a whole collection is permanently deleted, its entire <code>tainacan-items\/&lt;collection_id&gt;<\/code> folder is removed too.<\/p>\n\n<h3>Important notes<\/h3>\n\n<ul>\n<li>This is <strong>destructive and irreversible<\/strong>: files are deleted from disk, not sent to a trash. This is intentional \u2014 it is what the plugin exists to do.<\/li>\n<li>Each Tainacan item owns an isolated upload folder, so deleting it does not affect other items. The plugin does <strong>not<\/strong> scan metadata for attachments shared across items; if you reuse a single attachment across multiple items, deleting one item may remove that shared file.<\/li>\n<li>Sending an item to the trash does nothing \u2014 cleanup only happens on <strong>permanent<\/strong> deletion.<\/li>\n<\/ul>\n\n<!--section=installation-->\n<ol>\n<li>Upload the <code>bauhaus-file-cleanup-for-tainacan<\/code> folder to <code>\/wp-content\/plugins\/<\/code>, or install the ZIP via <strong>Plugins \u2192 Add New \u2192 Upload Plugin<\/strong>.<\/li>\n<li>Activate the plugin through the \"Plugins\" menu in WordPress.<\/li>\n<li>Ensure Tainacan is installed and active.<\/li>\n<li>Visit <strong>Settings \u2192 Bauhaus File Cleanup for Tainacan<\/strong> to toggle the behaviour on or off. The plugin defaults to enabled.<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt id=\"does%20it%20delete%20files%20when%20i%20just%20trash%20an%20item%3F\"><h3>Does it delete files when I just trash an item?<\/h3><\/dt>\n<dd><p>No. It only acts on permanent deletion (emptying the trash \/ \"delete permanently\").<\/p><\/dd>\n<dt id=\"can%20i%20keep%20the%20files%3F\"><h3>Can I keep the files?<\/h3><\/dt>\n<dd><p>Visit <strong>Settings \u2192 Bauhaus File Cleanup for Tainacan<\/strong> and uncheck the toggle. The plugin stays active but stops removing files. You can also deactivate the plugin entirely \u2014 with it inactive, WordPress\/Tainacan behave as before.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0.0<\/h4>\n\n<ul>\n<li>Initial release. Fixes orphaned files left by Tainacan on permanent deletion \u2014 including the private items \"<em>x<\/em>\" folders. Includes a settings page under Settings \u2192 Bauhaus File Cleanup for Tainacan with an enable\/disable toggle (defaults to enabled), path traversal protection, and recursive folder cleanup of all derivative sizes.<\/li>\n<\/ul>","raw_excerpt":"Removes a Tainacan item&#039;s documents, attachments and files from disk on permanent deletion, so deleted items stop leaving orphaned uploads behind.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/335352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=335352"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/bauhaustech"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=335352"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=335352"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=335352"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=335352"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=335352"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=335352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}