Skip to content

Instantly share code, notes, and snippets.

@stephensabatini
Last active March 21, 2018 02:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephensabatini/6bded03fc3ab78faaeab5ffb750b169c to your computer and use it in GitHub Desktop.
Save stephensabatini/6bded03fc3ab78faaeab5ffb750b169c to your computer and use it in GitHub Desktop.
Accessible and Translation-Ready Edit Links in WordPress from functions.php.
<?php
function filter_edit_post_link( $link, $post_id, $text ) {
if ( $text === __( 'Edit This' ) ) {
return str_replace( $text, sprintf( __( 'Edit<span class="screen-reader-text"> "%s"</span>' ), get_the_title() ), $text );
}
}
add_filter( 'edit_post_link', 'filter_edit_post_link', 10, 3 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment