[wp-trac] [WordPress Trac] #40359: allow arbitrary HTML attributes on <a> produced by Walker_Page
WordPress Trac
noreply at wordpress.org
Tue Apr 4 19:54:36 UTC 2017
#40359: allow arbitrary HTML attributes on <a> produced by Walker_Page
---------------------------+-----------------------------
Reporter: pbiron | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: accessibility |
---------------------------+-----------------------------
{{{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_Page}}} (i.e., add a
{{{page_menu_link_attributes}}} filter).
My immediate need is to add "aria-current='page'" to the <a> tag for the
current page in the output generated by {{{wp_page_menu()}}}. But other
potential uses would be to add "target='_blank'", etc.
My current workaround is to subclass {{{Walker_Page}}}, duplicating
{{{Walker_Page::start_el()}}} except for adding "aria-current='page'" when
{{{$page->ID === $current_page}}}. But that is far from ideal...as I will
have to track changes to {{{Walker_Page::start_el()}}} in future released
and update my subclass appropriately.
There may be other places across core where a similar filter would also be
useful (e.g., {{{Walker_Category}}}) and I'd be willing to look for those
other places if my proposed addition to {{{Walker_Page}}} is accepted as a
good idea.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40359>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list