WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#35250 new enhancement

Enable developer to omit "internal" taxonomies from return value of get_taxonomies()

Reported by: MikeSchinkel Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch needs-docs
Focuses: Cc:

Description

I frequently use one or two taxonomies in a project that users should never see, but plugins that use the get_taxonomies() function are able to display my internal taxonomies to users. get_taxonomies() does not filter for show_in_nav_menu or show_in_nav_menu _(and probably should not.)_ so I can't correct this proactively. Thus I would like to be able to filter out my internal taxonomies so they will be invisible to plugins and themes.

I am uploading a patch that adds a 'get_taxonomies' filter for this.

Another option would be to introduce a 'internal' property at taxonomy registration and then filter for that being false in get_taxonomies() and probably elsewhere, or introduce the idea of underscore prefixed taxonomies being hidden.

Any of those would work for me. Thanks in advance for considering.

Attachments (1)

35250.diff (603 bytes) - added by MikeSchinkel 2 years ago.
Adds 'get_taxonomies' filter

Download all attachments as: .zip

Change History (6)

@MikeSchinkel
2 years ago

Adds 'get_taxonomies' filter

#1 @johnbillion
2 years ago

  • Keywords has-patch needs-docs added
  • Version trunk deleted

#2 @MikeSchinkel
2 years ago

I'll be happy to add PHPDocs if adding it is blessed.

#3 @nofearinc
2 years ago

That sounds helpful to me as well, I don't see a filter in wp_filter_object_list either, so this one may come handy.

#4 follow-up: @dd32
2 years ago

I'm not sure we should make it easy for developers to "hide" their taxonomy, even if only used internally to their plugin or theme.

Rather, anyone who is listing taxonomies, should probably only list what makes sense in their context - for example, only showing taxonomies with public => true.

#5 in reply to: ↑ 4 @MikeSchinkel
2 years ago

Replying to dd32:

Rather, anyone who is listing taxonomies, should probably only list what makes sense in their context - for example, only showing taxonomies with public => true.

Sadly, that does not follow ''Postel's Law'':

Be conservative in what you do, be liberal in what you accept from others

Depending on others to do what they "should" be doing, especially in the WordPress plugin and theme ecosystem, is just asking for trouble. Much better for a developer to take steps to ensure someone else can't create a problem rather than hope that they do not.

Note: See TracTickets for help on using tickets.