Fix translatability of comments title.

As per the guidelines in https://codex.wordpress.org/I18n_for_WordPress_Developers#Plurals

This fixes an error notice which WPCS will start throwing once the - soon to be released - 0.10.0 version has become stable.
This commit is contained in:
jrfnl 2016-08-25 23:28:24 +02:00
parent 9700947f74
commit 8dbca77003
1 changed files with 13 additions and 5 deletions

View File

@ -27,11 +27,19 @@ if ( post_password_required() ) {
if ( have_comments() ) : ?>
<h2 class="comments-title">
<?php
printf( // WPCS: XSS OK.
esc_html( _nx( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'comments title', '_s' ) ),
number_format_i18n( get_comments_number() ),
'<span>' . get_the_title() . '</span>'
);
$comment_count = get_comments_number();
if ( 1 === $comment_count ) {
printf(
esc_html_e( 'One thought on &ldquo;%1$s&rdquo;', '_s' ),
'<span>' . get_the_title() . '</span>'
);
} else {
printf( // WPCS: XSS OK.
esc_html( _nx( '%1$s thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', $comment_count, 'comments title', '_s' ) ),
number_format_i18n( $comment_count ),
'<span>' . get_the_title() . '</span>'
);
}
?>
</h2><!-- .comments-title -->