From c60811bf942d6873dfd8a7e17a8658b5cb42dc30 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Fri, 26 Jun 2015 14:22:38 -0400 Subject: [PATCH 1/2] 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 --- inc/template-tags.php | 9 ++++++++- template-parts/content-page.php | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index fb865c0..e9ab284 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -123,7 +123,14 @@ function _s_entry_footer() { echo ''; } - edit_post_link( esc_html__( 'Edit', '_s' ), '', '' ); + edit_post_link( + sprintf( + esc_html_x( 'Edit %s', 'name of current post', '_s' ), + wp_kses( the_title( '"', '"', false ), array( 'span' => array( 'class' => array() ) ) ) + ), + '', + '' + ); } endif; diff --git a/template-parts/content-page.php b/template-parts/content-page.php index f0601c5..e837d96 100644 --- a/template-parts/content-page.php +++ b/template-parts/content-page.php @@ -23,7 +23,16 @@ From 0a0e5c631f0e481af7cb56efd801eb982164b4f6 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Thu, 2 Jul 2015 17:37:30 -0400 Subject: [PATCH 2/2] Add post title to `edit_post_link` * Use `__()` instead of `_x()` * Add translator comment, remove context modifier. * Remove escaping on `the_title()`; it's trusted data. Resolves: #774 --- inc/template-tags.php | 5 +++-- template-parts/content-page.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index e9ab284..6beb464 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -125,8 +125,9 @@ function _s_entry_footer() { edit_post_link( sprintf( - esc_html_x( 'Edit %s', 'name of current post', '_s' ), - wp_kses( the_title( '"', '"', false ), array( 'span' => array( 'class' => array() ) ) ) + /* translators: %s: Name of current post */ + esc_html__( 'Edit %s', '_s' ), + the_title( '"', '"', false ) ), '', '' diff --git a/template-parts/content-page.php b/template-parts/content-page.php index e837d96..d70c9d5 100644 --- a/template-parts/content-page.php +++ b/template-parts/content-page.php @@ -26,8 +26,9 @@ "', '"', false ), array( 'span' => array( 'class' => array() ) ) ) + /* translators: %s: Name of current post */ + esc_html__( 'Edit %s', '_s' ), + the_title( '"', '"', false ) ), '', ''