feat(recycle-bin): hide Media filter tab when MEDIA_TRASH is off#216
Merged
Conversation
The Recycle Bin's type-filter toolbar shipped a Media segment regardless of whether attachments could actually end up in trash. On a default WP install — `MEDIA_TRASH` defaults to false in `wp_initial_constants()` — the Media library permanent-deletes on first click, so that tab will never have rows under it and just confuses users. Render the Media segment conditionally on the constant being truthy. Sites that opt in via `define( 'MEDIA_TRASH', true );` in `wp-config.php` get the tab back. Sibling segments (Posts, Pages, Comments, Desktop) are unaffected. Adds a PHPUnit case for the default off-state. The on-state isn't reachable from PHPUnit because the constant is locked in `wp_initial_constants()` before tests load — documented in the test class and covered by manual QA.
✅ WordPress Plugin Check Report
📊 ReportAll checks passed! No errors or warnings found. 🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MEDIA_TRASHisfalse, so the Media library permanent-deletes attachments on first click and the bucket can never have rows — the tab always read empty and confused users.defined( 'MEDIA_TRASH' ) && MEDIA_TRASH. Sites that opt in viadefine( 'MEDIA_TRASH', true );inwp-config.phpget the tab back without any additional configuration.The constant is the right gate because attachments only ever end up in trash when WordPress itself routes them there — which only happens when
MEDIA_TRASHis truthy.Test plan