WordPress.org

Make WordPress Core

Opened 8 months ago

Last modified 8 months ago

#40178 new enhancement

Menus that contain post types in Draft status should be hidden from logged out users

Reported by: jdingman Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.7.3
Component: General Keywords: has-patch 2nd-opinion needs-testing
Focuses: ui, administration Cc:

Description

I recently added 2 pages to my site. I published them, and moved them into a Menu on my site.

Then realized, I don't want them public, but I also don't want to lose their positioning where I put them in the menu. I moved them to draft.

When I go to my site logged out, I still see the links and goes to a 404.

I'm proposing that when an item in the Menu moves to a non-published state that isn't the Trash (Draft or Pending), it should remain in the nav, but be hidden from any logged out users.

Attachments (4)

40178.diff (913 bytes) - added by bor0 8 months ago.
WP Admin Menus.png (32.5 KB) - added by lukecavanagh 8 months ago.
WP Admin Menus
40178.patch (4.7 KB) - added by desrosj 8 months ago.
40178.2.patch (3.7 KB) - added by desrosj 8 months ago.
Replaces space indentation with tabs. Still configuring new editor.

Download all attachments as: .zip

Change History (8)

#1 @bor0
8 months ago

I was able to reproduce this and I agree that it is a bug. Non-published pages do not appear on the dropdown list in Appearance > Menus. However, when once added to a menu, they will appear in the Menu Structure in wp-admin regardless of their publish status.

After proposed patch, unpublished items will appear as such "Name (Invalid)" on the wp-admin part.

@bor0
8 months ago

#2 @bor0
8 months ago

  • Keywords has-patch added

@lukecavanagh
8 months ago

WP Admin Menus

#3 @lukecavanagh
8 months ago

@bor0

Patch applies cleanly and works as expected.

@desrosj
8 months ago

#4 @desrosj
8 months ago

  • Keywords 2nd-opinion needs-testing added

I think that it would be better not to declare draft content in the menu as "invalid".

I added a new patch that shows draft items as orange with a new warning. They are then filtered out the same way as invalid items, but with a new filter function checking that the content is published.

Customizer support for this approach needs to be added.

@desrosj
8 months ago

Replaces space indentation with tabs. Still configuring new editor.

Note: See TracTickets for help on using tickets.