Make WordPress Core

Opened 8 years ago

Last modified 11 months ago

#36012 assigned enhancement

Add .current-ancestor class to any relative menu item ancestor

Reported by: vovkasolovev's profile vovkasolovev Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 4.4.2
Component: Menus Keywords: needs-unit-tests has-patch
Focuses: template Cc:

Description

Right now there is .current-page-ancestor and .current-post-ancestor for pages and posts and no any class for archives, category, taxonomy or custom post types ancestors added to items in nav-menu.

I think it will be usefull, for indication navigation depth purposes, to add .current-ancestor class to ANY menu item if "current page" is child/successor to anything in menu (parents, archive, category, taxonomy etc. menu items).

Attachments (3)

36012.patch (697 bytes) - added by Mista-Flo 5 years ago.
Add classes for all custom post types and custom taxonomies - current ancestors
36012.2.patch (1.7 KB) - added by Mista-Flo 5 years ago.
Refactoring
36012.3.patch (1.7 KB) - added by Mista-Flo 5 years ago.
Fix class name and avoid using sprintf

Download all attachments as: .zip

Change History (15)

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


8 years ago

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


8 years ago

#3 @SergeyBiryukov
8 years ago

  • Owner set to SergeyBiryukov
  • Status changed from new to assigned
  • Type changed from feature request to enhancement

#6 in reply to: ↑ 5 @vovkasolovev
5 years ago

Replying to JeffPaul:

A decision was made to reopen tickets that were closed in the bulk edit that this ticket was affected by. This ticket is being placed back into the Awaiting Review milestone so it can be individually evaluated and verified to determine if it is still relevant/valid or reproducible.

Patiently waiting for the .current-ancestor tag to indicate selected item in menu for archives, category, taxonomy and custom post types pages.

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

#8 @afercia
5 years ago

  • Milestone set to Future Release

#9 @SergeyBiryukov
5 years ago

  • Keywords needs-patch needs-unit-tests added

@Mista-Flo
5 years ago

Add classes for all custom post types and custom taxonomies - current ancestors

#10 follow-up: @Mista-Flo
5 years ago

  • Keywords has-patch added; needs-patch removed

The patch is really simple, instead of just adding this class for page, it add it for all custom post types and taxonomies.

Is unit tests really needed ?

#11 in reply to: ↑ 10 @vovkasolovev
5 years ago

Replying to Mista-Flo:

The patch is really simple, instead of just adding this class for page, it add it for all custom post types and taxonomies.

Sorry, If you decide to add specific type, maybe we can add both:
.current-ancestor and .current_%s_ancestor

Similar how we have with item classes:
.menu-item and .menu-item-type-taxonomy.

Reason to have short .current-ancestor (without %argument) for all the parents is to be able to select and to stylize menu items in bread crumbs way, without specifying their type, level or something else.

#12 follow-up: @Mista-Flo
5 years ago

Yeah sure it makes sense but you already have the general class "current-menu-ancestor", so I guess it's what you want.

By the way, I have added a new patch just for refactoring purpose, tried to merge some if state to avoid extra code lines.

@Mista-Flo
5 years ago

Refactoring

@Mista-Flo
5 years ago

Fix class name and avoid using sprintf

#13 in reply to: ↑ 12 @vovkasolovev
5 years ago

Replying to Mista-Flo:

Yeah sure it makes sense but you already have the general class "current-menu-ancestor", so I guess it's what you want.

Sorry, that is what I asked for. Right now there is no "current-menu-ancestor" (or "current-ancestor" as I named it) for CPT and archives. They have only type-related classes like "current-post-ancestor".

#14 @joedolson
11 months ago

  • Focuses accessibility removed

Looking at this issue and past discussions of it in the accessibility channel, I don't think that this needs the accessibility focus.

Note: See TracTickets for help on using tickets.