Escape translations in custom template tags.

See #737.
This commit is contained in:
Fränk Klein 2015-05-05 12:16:55 +02:00
parent ef1a884b6c
commit 6fea1077d8
1 changed files with 30 additions and 30 deletions

View File

@ -20,15 +20,15 @@ function the_posts_navigation() {
} }
?> ?>
<nav class="navigation posts-navigation" role="navigation"> <nav class="navigation posts-navigation" role="navigation">
<h2 class="screen-reader-text"><?php _e( 'Posts navigation', '_s' ); ?></h2> <h2 class="screen-reader-text"><?php esc_html_e( 'Posts navigation', '_s' ); ?></h2>
<div class="nav-links"> <div class="nav-links">
<?php if ( get_next_posts_link() ) : ?> <?php if ( get_next_posts_link() ) : ?>
<div class="nav-previous"><?php next_posts_link( __( 'Older posts', '_s' ) ); ?></div> <div class="nav-previous"><?php next_posts_link( esc_html__( 'Older posts', '_s' ) ); ?></div>
<?php endif; ?> <?php endif; ?>
<?php if ( get_previous_posts_link() ) : ?> <?php if ( get_previous_posts_link() ) : ?>
<div class="nav-next"><?php previous_posts_link( __( 'Newer posts', '_s' ) ); ?></div> <div class="nav-next"><?php previous_posts_link( esc_html__( 'Newer posts', '_s' ) ); ?></div>
<?php endif; ?> <?php endif; ?>
</div><!-- .nav-links --> </div><!-- .nav-links -->
@ -53,7 +53,7 @@ function the_post_navigation() {
} }
?> ?>
<nav class="navigation post-navigation" role="navigation"> <nav class="navigation post-navigation" role="navigation">
<h2 class="screen-reader-text"><?php _e( 'Post navigation', '_s' ); ?></h2> <h2 class="screen-reader-text"><?php esc_html_e( 'Post navigation', '_s' ); ?></h2>
<div class="nav-links"> <div class="nav-links">
<?php <?php
previous_post_link( '<div class="nav-previous">%link</div>', '%title' ); previous_post_link( '<div class="nav-previous">%link</div>', '%title' );
@ -83,12 +83,12 @@ function _s_posted_on() {
); );
$posted_on = sprintf( $posted_on = sprintf(
_x( 'Posted on %s', 'post date', '_s' ), esc_html_x( 'Posted on %s', 'post date', '_s' ),
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' '<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>'
); );
$byline = sprintf( $byline = sprintf(
_x( 'by %s', 'post author', '_s' ), esc_html_x( 'by %s', 'post author', '_s' ),
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' '<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
); );
@ -105,25 +105,25 @@ function _s_entry_footer() {
// Hide category and tag text for pages. // Hide category and tag text for pages.
if ( 'post' == get_post_type() ) { if ( 'post' == get_post_type() ) {
/* translators: used between list items, there is a space after the comma */ /* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', '_s' ) ); $categories_list = get_the_category_list( esc_html__( ', ', '_s' ) );
if ( $categories_list && _s_categorized_blog() ) { if ( $categories_list && _s_categorized_blog() ) {
printf( '<span class="cat-links">' . __( 'Posted in %1$s', '_s' ) . '</span>', $categories_list ); printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', '_s' ) . '</span>', $categories_list );
} }
/* translators: used between list items, there is a space after the comma */ /* translators: used between list items, there is a space after the comma */
$tags_list = get_the_tag_list( '', __( ', ', '_s' ) ); $tags_list = get_the_tag_list( '', esc_html__( ', ', '_s' ) );
if ( $tags_list ) { if ( $tags_list ) {
printf( '<span class="tags-links">' . __( 'Tagged %1$s', '_s' ) . '</span>', $tags_list ); printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', '_s' ) . '</span>', $tags_list );
} }
} }
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
echo '<span class="comments-link">'; echo '<span class="comments-link">';
comments_popup_link( __( 'Leave a comment', '_s' ), __( '1 Comment', '_s' ), __( '% Comments', '_s' ) ); comments_popup_link( esc_html__( 'Leave a comment', '_s' ), esc_html__( '1 Comment', '_s' ), esc_html__( '% Comments', '_s' ) );
echo '</span>'; echo '</span>';
} }
edit_post_link( __( 'Edit', '_s' ), '<span class="edit-link">', '</span>' ); edit_post_link( esc_html__( 'Edit', '_s' ), '<span class="edit-link">', '</span>' );
} }
endif; endif;
@ -140,45 +140,45 @@ if ( ! function_exists( 'the_archive_title' ) ) :
*/ */
function the_archive_title( $before = '', $after = '' ) { function the_archive_title( $before = '', $after = '' ) {
if ( is_category() ) { if ( is_category() ) {
$title = sprintf( __( 'Category: %s', '_s' ), single_cat_title( '', false ) ); $title = sprintf( esc_html__( 'Category: %s', '_s' ), single_cat_title( '', false ) );
} elseif ( is_tag() ) { } elseif ( is_tag() ) {
$title = sprintf( __( 'Tag: %s', '_s' ), single_tag_title( '', false ) ); $title = sprintf( esc_html__( 'Tag: %s', '_s' ), single_tag_title( '', false ) );
} elseif ( is_author() ) { } elseif ( is_author() ) {
$title = sprintf( __( 'Author: %s', '_s' ), '<span class="vcard">' . get_the_author() . '</span>' ); $title = sprintf( esc_html__( 'Author: %s', '_s' ), '<span class="vcard">' . get_the_author() . '</span>' );
} elseif ( is_year() ) { } elseif ( is_year() ) {
$title = sprintf( __( 'Year: %s', '_s' ), get_the_date( _x( 'Y', 'yearly archives date format', '_s' ) ) ); $title = sprintf( esc_html__( 'Year: %s', '_s' ), get_the_date( esc_html_x( 'Y', 'yearly archives date format', '_s' ) ) );
} elseif ( is_month() ) { } elseif ( is_month() ) {
$title = sprintf( __( 'Month: %s', '_s' ), get_the_date( _x( 'F Y', 'monthly archives date format', '_s' ) ) ); $title = sprintf( esc_html__( 'Month: %s', '_s' ), get_the_date( esc_html_x( 'F Y', 'monthly archives date format', '_s' ) ) );
} elseif ( is_day() ) { } elseif ( is_day() ) {
$title = sprintf( __( 'Day: %s', '_s' ), get_the_date( _x( 'F j, Y', 'daily archives date format', '_s' ) ) ); $title = sprintf( esc_html__( 'Day: %s', '_s' ), get_the_date( esc_html_x( 'F j, Y', 'daily archives date format', '_s' ) ) );
} elseif ( is_tax( 'post_format' ) ) { } elseif ( is_tax( 'post_format' ) ) {
if ( is_tax( 'post_format', 'post-format-aside' ) ) { if ( is_tax( 'post_format', 'post-format-aside' ) ) {
$title = _x( 'Asides', 'post format archive title', '_s' ); $title = esc_html_x( 'Asides', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) { } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
$title = _x( 'Galleries', 'post format archive title', '_s' ); $title = esc_html_x( 'Galleries', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-image' ) ) { } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
$title = _x( 'Images', 'post format archive title', '_s' ); $title = esc_html_x( 'Images', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-video' ) ) { } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
$title = _x( 'Videos', 'post format archive title', '_s' ); $title = esc_html_x( 'Videos', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) { } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
$title = _x( 'Quotes', 'post format archive title', '_s' ); $title = esc_html_x( 'Quotes', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-link' ) ) { } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
$title = _x( 'Links', 'post format archive title', '_s' ); $title = esc_html_x( 'Links', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-status' ) ) { } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
$title = _x( 'Statuses', 'post format archive title', '_s' ); $title = esc_html_x( 'Statuses', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) { } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
$title = _x( 'Audio', 'post format archive title', '_s' ); $title = esc_html_x( 'Audio', 'post format archive title', '_s' );
} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) { } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
$title = _x( 'Chats', 'post format archive title', '_s' ); $title = esc_html_x( 'Chats', 'post format archive title', '_s' );
} }
} elseif ( is_post_type_archive() ) { } elseif ( is_post_type_archive() ) {
$title = sprintf( __( 'Archives: %s', '_s' ), post_type_archive_title( '', false ) ); $title = sprintf( esc_html__( 'Archives: %s', '_s' ), post_type_archive_title( '', false ) );
} elseif ( is_tax() ) { } elseif ( is_tax() ) {
$tax = get_taxonomy( get_queried_object()->taxonomy ); $tax = get_taxonomy( get_queried_object()->taxonomy );
/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */ /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
$title = sprintf( __( '%1$s: %2$s', '_s' ), $tax->labels->singular_name, single_term_title( '', false ) ); $title = sprintf( esc_html__( '%1$s: %2$s', '_s' ), $tax->labels->singular_name, single_term_title( '', false ) );
} else { } else {
$title = __( 'Archives', '_s' ); $title = esc_html__( 'Archives', '_s' );
} }
/** /**