WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 6 months ago

#36012 assigned enhancement

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

Reported by: vovkasolovev Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version: 4.4.2
Component: Menus Keywords: needs-unit-tests has-patch
Focuses: accessibility, template Cc:
PR Number:

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 8 months ago.
Add classes for all custom post types and custom taxonomies - current ancestors
36012.2.patch (1.7 KB) - added by Mista-Flo 8 months ago.
Refactoring
36012.3.patch (1.7 KB) - added by Mista-Flo 8 months ago.
Fix class name and avoid using sprintf

Download all attachments as: .zip

Change History (14)

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


3 years ago

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


3 years ago

#3 @SergeyBiryukov
3 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
9 months 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.


9 months ago

#8 @afercia
9 months ago

  • Milestone set to Future Release

#9 @SergeyBiryukov
9 months ago

  • Keywords needs-patch needs-unit-tests added

@Mista-Flo
8 months ago

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

#10 follow-up: @Mista-Flo
8 months 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
8 months 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
8 months 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
8 months ago

Refactoring

@Mista-Flo
8 months ago

Fix class name and avoid using sprintf

#13 in reply to: ↑ 12 @vovkasolovev
8 months 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".

Note: See TracTickets for help on using tickets.