Last active
June 14, 2018 09:31
-
-
Save jrfnl/24410c92e108ecdb2dca55ed23515361 to your computer and use it in GitHub Desktop.
201805 WCEU Code samples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Example of translators comment for a text string with a single placeholder. | |
*/ | |
/* translators: %s: the version number of a WordPress release. */ | |
esc_html_e( 'Wordpress %s is awesome!' ); | |
/* | |
* Example of translators comment for a text string with multiple numbered placeholders. | |
*/ | |
/* translators: 1: the version number of the current WordPress release; 2: the version number which will come after that. */ | |
esc_html_e( 'Wordpress %1$s is awesome! and %2$s will be even better' ); | |
/* | |
* Example of INCORRECTLY placed translators comment. | |
*/ | |
/* translators: %s is the version number of a WordPress release. */ | |
echo '<h2>' . sprintf( | |
esc_html__( 'Some translatable text with %s placeholder' ), $replacement | |
); | |
/* | |
* Example of CORRECTLY placed translators comment. | |
*/ | |
echo '<h2>' . sprintf( | |
/* translators: %s is the version number of a WordPress release. */ | |
esc_html__( 'Some translatable text with %s placeholder' ), | |
$replacement | |
); | |
/* | |
* Examples of CORRECTLY placed translators comment and code layout when dealing with embedded PHP. | |
*/ | |
<?php /* translators: %s is the version number of a WordPress release. */ ?> | |
<h2> <?php printf( esc_html__( 'Some translatable text with %s placeholder' ), $replacement ); ?></h2> | |
<!-- Alternative code layouts: --> | |
<?php | |
/* translators: %s is the version number of a WordPress release. */ | |
$text = sprintf( __( 'Some translatable text with %s placeholder' ), $replacement ); | |
?> | |
<h2> <?php echo esc_html( $text ); ?></h2> | |
<h2> | |
<?php | |
printf( | |
/* translators: %s is the version number of a WordPress release. */ | |
esc_html__( 'Some translatable text with %s placeholder' ), | |
$replacement | |
); | |
?> | |
</h2> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment