[wp-trac] [WordPress Trac] #35267: menu-item-object class allows CPTs/Taxonomies to use "custom" slug

WordPress Trac noreply at wordpress.org
Wed Dec 30 18:55:45 UTC 2015


#35267: menu-item-object class allows CPTs/Taxonomies to use "custom" slug
-----------------------------+------------------------------
 Reporter:  RachieVee        |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Menus            |     Version:  4.4
 Severity:  normal           |  Resolution:
 Keywords:  has-screenshots  |     Focuses:
-----------------------------+------------------------------
Changes (by morganestes):

 * keywords:   => has-screenshots


Old description:

> This is a bug that includes the '''.menu-item-object-{custom}''' class
> that gets added to wp_nav_menu items:
>
> http://codex.wordpress.org/Function_Reference/wp_nav_menu#All_Menu_Items
>
> I ran a test locally on WP 4.4. The Codex claimed this class, '''.menu-
> item-object-{custom}''', gets applied to menu items that are CPTs and
> Custom Taxonomies.
>
> However, I was seeing it applied to Custom Links. (Edited the Codex to
> reflect that.) So now it's clear to me that .menu-item-object gets
> applied to Custom Links but then I got curious about the CPTs/Custom
> Taxonomies.
>
> CPTs and Custom Taxonomies get a class of '''.menu-item-object-{slug-of-
> cpt-or-taxonomy}'''.
>
> I discovered that I can register a CPT or Custom Taxonomy using the slug
> "custom". So that on the front-end the CPT/Custom Taxonomy menu items get
> a class of '''.menu-item-object-custom''', therefore conflicting with
> that class used for custom links instead. I get the impression that the
> class for custom links and class for CPTs/Custom Taxonomies should be
> entirely different entities? Or if anything, the slug "custom" shouldn't
> be allowed to be registered or it may conflict due to custom links using
> the same class.
>
> See lines around 536 of wp-includes/nav-menu-template.php for reference.

New description:

 This is a bug that includes the '''.menu-item-object-{custom}''' class
 that gets added to wp_nav_menu items:

 http://codex.wordpress.org/Function_Reference/wp_nav_menu#All_Menu_Items

 I ran a test locally on WP 4.4. The Codex claimed this class, '''.menu-
 item-object-{custom}''', gets applied to menu items that are CPTs and
 Custom Taxonomies.

 However, I was seeing it applied to Custom Links. (Edited the Codex to
 reflect that.) So now it's clear to me that .menu-item-object gets applied
 to Custom Links but then I got curious about the CPTs/Custom Taxonomies.

 CPTs and Custom Taxonomies get a class of '''.menu-item-object-{slug-of-
 cpt-or-taxonomy}'''.

 I discovered that I can register a CPT or Custom Taxonomy using the slug
 "custom". So that on the front-end the CPT/Custom Taxonomy menu items get
 a class of '''.menu-item-object-custom''', therefore conflicting with that
 class used for custom links instead. I get the impression that the class
 for custom links and class for CPTs/Custom Taxonomies should be entirely
 different entities? Or if anything, the slug "custom" shouldn't be allowed
 to be registered or it may conflict due to custom links using the same
 class.

 See [source:/tags/4.4/src/wp-includes/nav-menu-template.php#L536] for
 reference.

--

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35267#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list