WordPress.org

Make WordPress Core

Opened 7 years ago

Last modified 4 weeks ago

#16828 new enhancement

Add filter on initial_meta_boxes for nav menu

Reported by: aaroncampbell Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: has-patch has-screenshots ui-feedback
Focuses: ui Cc:

Description

When you create a custom post type with show_in_nav_menus = true the metabox in Appearance->Menus is hidden to all new users. This is especially annoying for multi-site setups. The issue is in wp_initial_nav_menu_meta_boxes() where it sets the initial meta boxes:

$initial_meta_boxes = array( 'nav-menu-theme-locations', 'add-custom-links', 'add-page', 'add-category' );

I'd settle for a filter on that, but it seems like a more complete fix would be to add the filter with a default function hooked into it which would add post types with show_in_nav_menus = true to the list.

Attachments (3)

nav-menu.php.diff.patch (645 bytes) - added by layotte 4 years ago.
proposed fix
nav-menu.diff (735 bytes) - added by louisremi 4 years ago.
Patch with more specific hook name
16828.diff (2.5 KB) - added by barryceelen 4 weeks ago.
Boldly deprecate wp_initial_nav_menu_meta_boxes()

Download all attachments as: .zip

Change History (12)

#1 @layotte
4 years ago

Working on a plugin now that is running into a similar issue. For first-time users of the nav-menu who have our custom nav menu activated, it will not appear on the nav menu screen (unless they select it). We should be able to set our nav menus as visible by default upon viewing the nav-menus.php page initially.

@layotte
4 years ago

proposed fix

#2 @SergeyBiryukov
4 years ago

#24256 was marked as a duplicate.

#3 @louisremi
4 years ago

My bug has just been closed as duplicate from this one.
I came up with a patch similar to the one proposed by layotte but with a more specific name for the hook (because this feature is really specific to nav menus).

@louisremi
4 years ago

Patch with more specific hook name

#4 @Chouby
4 years ago

  • Cc frederic.demarle@… added

+1 for this filter as some users don't have the idea to go in the screen options but go directly to the support forum...

#5 @lenasterg
3 years ago

+1 for this filter. Very useful for multisite installations

#6 @moreauf
2 years ago

Wouldn't it make sense for this screen to make use of the already existing default_hidden_meta_boxes filter?

#7 @barryceelen
4 weeks ago

  • Keywords has-patch has-screenshots ui-feedback added

This threw me off for a bit after registering a custom post type.

IMHO this limitation should be deprecated/removed entirely.

The function was introduced in 3.0 with a new menu editor. The way the meta boxes were displayed at the time quickly lead to a very loooong page, even when there were only core menu items visible. Limiting the number of meta boxes shown made sense.

This is not the case any more. The collapsed accordion does not cause a long page like it used to (subjective, I know), even if the core Tags and Post Formats (?) are not filtered out.

It does however cause the need to document/support "How do I add menu items for custom post types registered by [insert plugin name]??".

Then:

https://cobbledco.de/wp-content/uploads/2017/09/super-long-menu-edit-wp30.png

Now:

http://cobbledco.de/wp-content/uploads/2017/09/super-short-menu-edit-wp48.png

Last edited 4 weeks ago by barryceelen (previous) (diff)

#8 @barryceelen
4 weeks ago

  • Focuses ui added

@barryceelen
4 weeks ago

Boldly deprecate wp_initial_nav_menu_meta_boxes()

#9 @barryceelen
4 weeks ago

#41820 was marked as a duplicate.

Note: See TracTickets for help on using tickets.