#40666 closed enhancement (fixed)
allow arbitrary HTML attributes on <a> produced by Walker_Category
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 5.2 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | has-patch commit has-dev-note |
Focuses: | accessibility | Cc: |
Description
Walker_Nav_Menu
currently allows arbitrary HTML attributes to be added to the <a> tags it generates via the nav_menu_link_attributes
filter.
It would be useful to do the same in Walker_Category
(i.e., add a category_menu_link_attributes
filter).
Related: #40359
Attachments (3)
Change History (33)
#2
@
6 years ago
- Focuses accessibility added
Another thing I noticed while putting together this patch is that there is a difference in the way wp_list_categories()
and wp_list_pages()
invoke Walker::walk()
(via walk_category_tree()
and walk_page_tree()
, respectively).
Namely, wp_list_pages()
passes the current page as a param to walk_page_tree()
, whereas wp_list_categories()
does not pass the current category as a param to walk_category_tree()
, passing it instead $r['current_category']
.
As a result, those hooking into the new filter proposed here need to write their funcs slightly different than the similar filters for nav_menu_link_attributes
and page_menu_link_attributes
, as in:
add_filter( 'category_menu_link_attributes', 'add_aria_current_category', 10, 5 ); function add_aria_current_category( $atts, $category, $depth, $args, $id ) { if ( $category->term_id === $id || ( isset( $args['current_category'] ) && $category->term_id === $args['current_category'] ) ) { $atts['aria-current'] = 'page' ; } return $atts ; }
I think it might make sense to include a note about this different in the inline docs (resulting in the note appearing in DevHub. Alternatively, the note could be added a "comment" on the DevHub page for the new filter. I'd like feedback on this as well.
This ticket was mentioned in Slack in #accessibility by pbiron. View the logs.
6 years ago
This ticket was mentioned in Slack in #core by pbiron. View the logs.
6 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
6 years ago
#7
@
6 years ago
- Milestone changed from Awaiting Review to Future Release
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
5 years ago
This ticket was mentioned in Slack in #accessibility by rianrietveld. View the logs.
5 years ago
#10
follow-up:
↓ 11
@
5 years ago
- Milestone changed from Future Release to 4.9.9
Discussed during today's accessibility bug-scrub an agreed we'd like to propose this for 4.9.9 consideration. /Cc @SergeyBiryukov
This ticket was mentioned in Slack in #core by desrosj. View the logs.
4 years ago
#16
@
4 years ago
- Milestone changed from 5.0.3 to 5.1
Going to punt this to 5.1. It is outside of the scope for 5.0.3 (block
editor bugs, regressions, and major bugs). The patch still applies cleanly for me. Whoever ends up reviewing and committing this will just need to change the @since
tag.
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
4 years ago
This ticket was mentioned in Slack in #accessibility by afercia. View the logs.
4 years ago
This ticket was mentioned in Slack in #accessibility by pbiron. View the logs.
4 years ago
#23
@
4 years ago
- Keywords commit added
40666.3.diff makes phpcs happy and boyscouts a missing translators comment.
#24
@
4 years ago
Thanx for the updates!
Before this gets committed, does anyone have a reaction to the question I asked in https://core.trac.wordpress.org/ticket/40666#comment:1 re: the name of the filter?
This ticket was mentioned in Slack in #core by afercia. View the logs.
4 years ago
#27
in reply to:
↑ 1
@
4 years ago
Replying to pbiron:
To the best of my knowledge, in core
Walker_Category
is only used bywp_list_categories()
andwp_list_categories()
is only used byWP_Widget_Categories
.
As a result, I'm not sure that the name of new filter introduced in my patch (
category_menu_link_attributes
) is appropriate. I named it that to mirror the new filter introduced in #40359...which was named after the existing filter inWalker_Nav_Menu
.
I'd like some feedback on the naming (and inline docs) for this new filter.
In hindsight, page_menu_link_attributes
could probably have been called page_list_link_attributes
, as Walker_Page
is only used directly in wp_list_pages()
, via walk_page_tree()
.
However, wp_list_pages()
is also used in wp_page_menu()
, so page_menu_link_attributes
seemed to make sense in that regard.
For categories, I think category_list_link_attributes
would make sense without deviating too much from the existing naming of page_menu_link_attributes
and nav_menu_link_attributes
.
To the best of my knowledge, in core
Walker_Category
is only used bywp_list_categories()
andwp_list_categories()
is only used by `WP_Widget_Categories'.As a result, I'm not sure that the name of new filter introduced in my patch (
category_menu_link_attributes
) is appropriate. I named it that to mirror the new filter introduced in #40359...which was named after the existing filter inWalker_Nav_Menu
.I'd like some feedback on the naming (and inline docs) for this new filter.