[wp-trac] [WordPress Trac] #40359: allow arbitrary HTML attributes on <a> produced by Walker_Page
WordPress Trac
noreply at wordpress.org
Mon May 1 22:38:46 UTC 2017
#40359: allow arbitrary HTML attributes on <a> produced by Walker_Page
-------------------------+-----------------------------
Reporter: pbiron | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Menus | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses: accessibility
-------------------------+-----------------------------
Comment (by SergeyBiryukov):
> 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.
Using `wp_page_menu` filter to piggyback on the parent `<li>` element's
`current_page_item` class could be a simpler workaround:
{{{
function wp40359_add_aria_current( $output ) {
$output = preg_replace(
'#current_page_item(.*?)"><a #',
'current_page_item$1"><a aria-current="page" ',
$output
);
return $output;
}
add_filter( 'wp_page_menu', 'wp40359_add_aria_current' );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40359#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list