Media Trash
Product: Admin Framework Pro
The Media Trash module adds a safety net to your WordPress Media Library by sending deleted media files to a Trash folder instead of removing them permanently. This makes it easy to restore items if deleted by mistake, helping prevent data loss and accidental removals.
How to use
To enable the Media Trash module:
- Click on the “Admin Tools” category
- Search or scroll to locate the Media Trash module
- Click on the switch to enable
Important: WordPress requires the Media Trash feature to be enabled at the core level. Add the following line to your
wp-config.php(before “That’s all, stop editing!”):
phpdefine('MEDIA_TRASH', true);What’s next?
With Media Trash enabled:
- Deleting a media item moves it to a Trash view instead of permanent deletion.
- You can restore items from Trash or permanently delete them later.
Where you’ll see it:
- In Media > Library, a “Trash” view will appear.
- “Delete” actions move media to Trash; “Restore” and “Delete Permanently” are available in Trash.
Notes
- The module ensures Media Trash is active and warns you if it’s not properly initialized.
- If
MEDIA_TRASHisn’t defined or is set tofalse, the module shows an admin notice and may deactivate itself.
Best Practices
- Keep Media Trash enabled in
wp-config.phpto prevent accidental permanent deletions. - Periodically empty Trash to keep your library clean.
Troubleshooting
- “Media Trash module was not initialized properly” notice:
- Define
MEDIA_TRASHinwp-config.phpas shown above. - Reactivate the module if prompted.
- Define
- “Media Trash is currently disabled” notice:
- Ensure
define('MEDIA_TRASH', true);exists inwp-config.php.
- Ensure
- No Trash view in Media Library:
- Confirm the module is enabled and
MEDIA_TRASHis true. - Check user permissions for media management.
- Confirm the module is enabled and
Compatibility & Notes
- Works with the standard WordPress Media Library.
- Applies only to media items; post/page Trash is independent.
Developer notes
- The module displays admin notices and auto-deactivates if Media Trash isn’t enabled at the core level.
- Reference:
- Base: wp-content/plugins/WPMazic-pro/modules/media-trash/Bootstrap.php
- Pro logic: wp-content/plugins/WPMazic-pro/modules/media-trash/pro/Bootstrap.php
- Status checks and notices: checkMediaTrashStatus(), getMediaTrashStatus()
- Deactivation when disabled: maybeDisableModule()
This module is perfect for:
- Safeguarding media from accidental permanent deletion
- Allowing editors to restore media without backups