[wp-trac] [WordPress Trac] #40359: allow arbitrary HTML attributes on <a> produced by Walker_Page
WordPress Trac
noreply at wordpress.org
Tue Apr 4 20:01:42 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 | Resolution:
Keywords: has-patch | Focuses: accessibility
-------------------------+------------------------------
Comment (by pbiron):
And here is a sample of a func I'd hook into the filter to satisfy my
immediate need:
{{{
add_filter ('page_menu_link_attributes', 'add_aria_current', 10, 5) ;
function
add_aria_current ($attrs = array (), $page, $depth, $args, $current_page)
{
if ($page->ID === $current_page) {
$attrs['aria-current'] = 'page' ;
}
// if (my_is_external_link_func (get_permalink ($page->ID))) {
// $attrs['target'] = '_blank' ;
// }
return ($attrs) ;
}
}}}
which, as you can see, would be **much** cleaner (and more future-proof)
than my current workaround of subclassing {{{Walker_Page}}}.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40359#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list