Add post title to `edit_post_link`

This improves the accessibility of these links, and gives more context for screen reader users. Now, they know exactly where the link goes.

Escaped output with `esc_html_x` and `wp_kses`.

Resolves: #774
This commit is contained in:
David A. Kennedy 2015-06-26 14:22:38 -04:00
parent 5bb0534358
commit c60811bf94
2 changed files with 18 additions and 2 deletions

View File

@ -123,7 +123,14 @@ function _s_entry_footer() {
echo '</span>'; echo '</span>';
} }
edit_post_link( esc_html__( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); edit_post_link(
sprintf(
esc_html_x( 'Edit %s', 'name of current post', '_s' ),
wp_kses( the_title( '<span class="screen-reader-text">"', '"</span>', false ), array( 'span' => array( 'class' => array() ) ) )
),
'<span class="edit-link">',
'</span>'
);
} }
endif; endif;

View File

@ -23,7 +23,16 @@
</div><!-- .entry-content --> </div><!-- .entry-content -->
<footer class="entry-footer"> <footer class="entry-footer">
<?php edit_post_link( esc_html__( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); ?> <?php
edit_post_link(
sprintf(
esc_html_x( 'Edit %s', 'name of current post', '_s' ),
wp_kses( the_title( '<span class="screen-reader-text">"', '"</span>', false ), array( 'span' => array( 'class' => array() ) ) )
),
'<span class="edit-link">',
'</span>'
);
?>
</footer><!-- .entry-footer --> </footer><!-- .entry-footer -->
</article><!-- #post-## --> </article><!-- #post-## -->