ADA - Add Aria Label to link

PHOTO EMBED

Wed Jan 27 2021 14:28:21 GMT+0000 (UTC)

Saved by @devwebdev #wordpress #ada #accessibility

//add aria label to link that opens in new tab
function aria_formatter($content) {
$replace = array('target="_blank"' => 'target="_blank" aria-label="Opens in a new tab."');
$new_content = strtr($content, $replace);
return $new_content;
}
add_filter('the_content', 'aria_formatter', 999);
content_copyCOPY

Add this to functions.php to your theme and it will add the aria-label to a link that opens in new tabs.