Last active
March 21, 2018 02:54
-
-
Save stephensabatini/6bded03fc3ab78faaeab5ffb750b169c to your computer and use it in GitHub Desktop.
Accessible and Translation-Ready Edit Links in WordPress from functions.php.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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