Make WordPress Core

Opened 23 months ago

Last modified 22 months ago

#37916 new enhancement

Customize: ability to disable content creation in menus

Reported by: celloexpressions Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: needs-patch
Focuses: Cc:


There should be a hook to disable the ability to create new posts (and eventually terms, see #37915) in nav menus in the customizer. Ideally, it should be able to be disabled for specific post types as well as all post types. For terms, we'll need to turn it off for the post_format taxonomy.

This is being split out from the initial merge in #34923, where there are patches with an approach we could take here.

Attachments (2)

37916.diff (2.6 KB) - added by jorbin 22 months ago.
37916.2.diff (1.3 KB) - added by jorbin 22 months ago.

Download all attachments as: .zip

Change History (10)

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.

23 months ago

This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.

22 months ago

#3 @jorbin
22 months ago

@celloexpressions Now that #34923 has been committed, is this something you want to revist?

#4 @celloexpressions
22 months ago

@jorbin this was created after that commit :) Still waiting for dev feedback here, if you have any, please provide.

We're kind of waiting for #37914 as term support might change the approach here. My preference would still be to have something that can work for both post and term objects, though, and filters an array that contains only taxonomy_post_format as a disallowed type by default. Passing __return_false to that filter would disable the feature for all post types and taxonomies.

#5 @jorbin
22 months ago

@celloexpressions totally missed the timing :) sorry about that.

I'm considerably less familiar with the customizor code, so I would likely defer to you or @westonruter, but perhaps a filter that is in ajax_insert_auto_draft_post and whatever handler is used for taxonomies who's value is also output as a JS var that can be used to decide if we should show the add new box and button?

Last edited 22 months ago by jorbin (previous) (diff)

22 months ago

#6 @jorbin
22 months ago

Above patch is a proof of concept of my idea.

22 months ago

#7 @jorbin
22 months ago

This time without another patch I was testing :)

#8 @westonruter
22 months ago

  • Keywords dev-feedback removed
  • Milestone changed from 4.7 to Future Release

I don't think we currently *need* a way to turn off the ability to create stubs for nav menu items. Since the post_format taxonomy is the only known use case for needing to turn off stub creation, and since term stubs aren't going to be part of 4.7 (per #37915) I think we can punt this to Future Release.

And the ticket isn't about turning off stub creation _entirely_ but rather turning off stub creation for specific object types. So in 37916.2.diff the customize_create_nav_menu_content filter would need to be amended with additional context for the specific post_type or taxonomy.

Note: See TracTickets for help on using tickets.