Opened 13 years ago
Closed 8 years ago
#19038 closed defect (bug) (fixed)
Menu Items aren't deleting on page being trashed, only when deleted
Reported by: | jeremyatignition | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 3.2.1 |
Component: | Menus | Keywords: | has-patch commit has-screenshots has-unit-tests |
Focuses: | Cc: |
Description
The linked menu item for a page isn't removed when the page is trashed.
Attachments (3)
Change History (19)
#3
@
11 years ago
Just wanted to say this works like a charm for me. I can even add that line into a plugin or my functions.php file.
#6
@
9 years ago
- Keywords needs-refresh added
Patch needs a refresh.
What if you're just temporarily trashing a page to untrash it again a bit later?
I think a menu item of a trashed object should show as invalid in the admin and not show up at all on the front-end.
#7
follow-up:
↓ 8
@
9 years ago
Honest question: when is it better to trash a page rather than just set it to draft to temporarily remove it? I'd consider trashing a page as intent to never get it back. This may just be my opinion/preference though and not the majority of other user's way.
#8
in reply to:
↑ 7
;
follow-up:
↓ 9
@
9 years ago
Replying to Jpyper:
Honest question: when is it better to trash a page rather than just set it to draft to temporarily remove it? I'd consider trashing a page as intent to never get it back. This may just be my opinion/preference though and not the majority of other user's way.
True. I was just giving an example. There's a reason why this wasn't implemented for trashed pages. My suggestion is still the same as pages or posts can be untrashed.
#9
in reply to:
↑ 8
@
9 years ago
Replying to swissspidy:
Replying to Jpyper:
Honest question: when is it better to trash a page rather than just set it to draft to temporarily remove it? I'd consider trashing a page as intent to never get it back. This may just be my opinion/preference though and not the majority of other user's way.
True. I was just giving an example. There's a reason why this wasn't implemented for trashed pages. My suggestion is still the same as pages or posts can be untrashed.
I don't know if I've ever seen that "invalid" menu item scenario come up before, I just had to look it up. That actually sounds better. The main goal is to have the menu item not show on the front end if it's object was trashed. It would be nice to make it easy to reinstate that menu item just by bringing the object back (as long as it's not removed from the DB, obviously).
#10
@
9 years ago
- Keywords ux-feedback added; dev-feedback needs-refresh removed
The main goal is to have the menu item not show on the front end if it's object was trashed. It would be nice to make it easy to reinstate that menu item just by bringing the object back (as long as it's not removed from the DB, obviously).
That's how it's currently working. When you trash a page, the menu item isn't shown on the front-end.
19038.diff sets the 'Invalid' flag in the admin to any menu items which have trashed parent objects. The same flag is set when the post type does not exist anymore.
Needs UX review. Perhaps a red warning is too much in this case.
#12
@
8 years ago
- Milestone changed from Future Release to 4.7
I think a menu item of a trashed object should show as invalid in the admin and not show up at all on the front-end.
Just ran into this again. When I add a page or post to the menu and trash it, the menu item is still visible on the front-end. The permalink changes to http://src.wordpress-develop.dev/<slug>__trashed/
as expected because the slug changes when trashing. There's no indication when editing the menu that the post/page is trashed either.
#14
@
8 years ago
- Keywords commit has-screenshots added; ux-feedback removed
19038.2.diff still applies cleanly. A trashed page isn't displayed in the nav menu anymore.
Here's how a deleted page is shown in the menu editor with the patch applied.
This is because
_wp_delete_post_menu_item
is only hooked to thedelete_post
action.Patch adds the same hook to the trash action. Of course this means that if you restore the post then the menu item has to be restored manually if you still want it - but this seems better than having to delete the menu item manually when you trash a post.