From edfc674e795386ee7597af8cbdc375bddc6fce20 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Fri, 4 Oct 2019 21:36:01 +0200 Subject: [PATCH] PHPCS: i18n functions are considered safe for core translations. (#734) * PHPCS: i18n functions are considered safe for core translations. * Remove obsolete phpcs:ignore comments * Don't escape translations --- 404.php | 4 +-- classes/class-twentytwenty-customize.php | 2 +- classes/class-twentytwenty-walker-comment.php | 13 +++++--- comments.php | 31 ++++++++--------- footer.php | 16 ++++----- functions.php | 10 +++--- header.php | 8 ++--- inc/template-tags.php | 14 ++++---- phpcs.xml.dist | 33 +++++++++++++++---- template-parts/content-cover.php | 4 +-- template-parts/entry-author-bio.php | 4 +-- template-parts/entry-header.php | 2 +- template-parts/modal-menu.php | 10 +++--- template-parts/modal-search.php | 2 +- 14 files changed, 84 insertions(+), 69 deletions(-) diff --git a/404.php b/404.php index 2a900d2be..fbf509aa8 100644 --- a/404.php +++ b/404.php @@ -14,9 +14,9 @@
-

+

-

+

esc_html__( 'Header & Footer Background Color', 'twentytwenty' ), + 'label' => __( 'Header & Footer Background Color', 'twentytwenty' ), 'section' => 'colors', ) ) diff --git a/classes/class-twentytwenty-walker-comment.php b/classes/class-twentytwenty-walker-comment.php index 20026c1f8..62afb04e1 100644 --- a/classes/class-twentytwenty-walker-comment.php +++ b/classes/class-twentytwenty-walker-comment.php @@ -50,8 +50,11 @@ protected function html5_comment( $comment, $depth, $args ) { } } - /* Translators: '%1$s = comment author name */ - printf( '%1$s%2$s', esc_html( $comment_author ), __( 'says:', 'twentytwenty' ) ); // phpcs:ignore + printf( + '%1$s%2$s', + esc_html( $comment_author ), + __( 'says:', 'twentytwenty' ) + ); if ( ! empty( $comment_author_url ) ) { echo ''; @@ -71,7 +74,7 @@ protected function html5_comment( $comment, $depth, $args ) { ' . __( 'Edit', 'twentytwenty' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations + echo ' • ' . __( 'Edit', 'twentytwenty' ) . ''; } ?>
@@ -86,7 +89,7 @@ protected function html5_comment( $comment, $depth, $args ) { if ( '0' === $comment->comment_approved ) { ?> -

+

' . __( 'By Post Author', 'twentytwenty' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations + echo '' . __( 'By Post Author', 'twentytwenty' ) . ''; } ?> diff --git a/comments.php b/comments.php index df7c3763a..7ff3a306f 100644 --- a/comments.php +++ b/comments.php @@ -31,24 +31,22 @@

new TwentyTwenty_Walker_Comment(), @@ -127,7 +124,7 @@
-

+

diff --git a/footer.php b/footer.php index 27aaa0398..437ef7e4f 100644 --- a/footer.php +++ b/footer.php @@ -20,11 +20,9 @@

- +

@@ -44,13 +40,13 @@ ' ); + printf( __( 'To the top %s', 'twentytwenty' ), '' ); ?> ' ); + printf( __( 'Up %s', 'twentytwenty' ), '' ); ?> diff --git a/functions.php b/functions.php index 225743048..e22cbef03 100644 --- a/functions.php +++ b/functions.php @@ -284,7 +284,7 @@ function wp_body_open() { * Include a skip to content link at the top of the page so that users can bypass the menu. */ function twentytwenty_skip_link() { - echo ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- core trusts translations + echo ''; } add_action( 'wp_body_open', 'twentytwenty_skip_link', 5 ); @@ -398,17 +398,17 @@ function twentytwenty_block_editor_settings() { // Block Editor Palette. $editor_color_palette = array( array( - 'name' => esc_html__( 'Accent Color', 'twentytwenty' ), + 'name' => __( 'Accent Color', 'twentytwenty' ), 'slug' => 'accent', 'color' => twentytwenty_get_color_for_area( 'content', 'accent' ), ), array( - 'name' => esc_html__( 'Secondary', 'twentytwenty' ), + 'name' => __( 'Secondary', 'twentytwenty' ), 'slug' => 'secondary', 'color' => twentytwenty_get_color_for_area( 'content', 'secondary' ), ), array( - 'name' => esc_html__( 'Subtle Background', 'twentytwenty' ), + 'name' => __( 'Subtle Background', 'twentytwenty' ), 'slug' => 'subtle-background', 'color' => twentytwenty_get_color_for_area( 'content', 'borders' ), ), @@ -480,7 +480,7 @@ function twentytwenty_read_more_tag() { return sprintf( '%2$s "%3$s"', esc_url( get_permalink( get_the_ID() ) ), - esc_html__( 'Continue reading', 'twentytwenty' ), + __( 'Continue reading', 'twentytwenty' ), esc_html( get_the_title( get_the_ID() ) ) ); } diff --git a/header.php b/header.php index 43d21dc56..467f602ba 100644 --- a/header.php +++ b/header.php @@ -50,7 +50,7 @@ - + @@ -73,7 +73,7 @@ - + @@ -143,7 +143,7 @@ diff --git a/inc/template-tags.php b/inc/template-tags.php index e0d9fc90c..987eb8d5a 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -291,14 +291,14 @@ function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' ) ?>
  • - + - +
  • - - + + - + - + - - - + + + @@ -56,4 +56,23 @@ + + + + + + + + + + + + + + + + + + + diff --git a/template-parts/content-cover.php b/template-parts/content-cover.php index 665d08472..74a8a334f 100644 --- a/template-parts/content-cover.php +++ b/template-parts/content-cover.php @@ -67,7 +67,7 @@ ?>
    - +
    @@ -85,7 +85,7 @@
    -
    +
    diff --git a/template-parts/entry-author-bio.php b/template-parts/entry-author-bio.php index b6ddcdb2c..28c6dd12a 100644 --- a/template-parts/entry-author-bio.php +++ b/template-parts/entry-author-bio.php @@ -17,7 +17,7 @@ @@ -26,7 +26,7 @@

    diff --git a/template-parts/entry-header.php b/template-parts/entry-header.php index 09acdbc50..1f685503c 100644 --- a/template-parts/entry-header.php +++ b/template-parts/entry-header.php @@ -33,7 +33,7 @@ ?>
    - +
    diff --git a/template-parts/modal-menu.php b/template-parts/modal-menu.php index bfd8b4a33..c84cceac9 100644 --- a/template-parts/modal-menu.php +++ b/template-parts/modal-menu.php @@ -18,7 +18,7 @@