WordPress String Translation Escaping Example
<?php | |
echo '<p>' . __('This is some text that needs to be translatable in my WordPress plugin', 'myplugin') . '</p>'; |
<?php | |
echo '<p>' . esc_html__('This text is still translatable in my WordPress plugin, but it also safe because it is escaped before being output.', 'myplugin') . '</p>'; |
<?php | |
echo '<a href="#" title="' . __('The title attribute in this link needs to be translatable', 'myplugin') . '">' . __('The anchor text also needs to be translatable', 'myplugin') . '</a>'; |
<?php | |
echo '<a href="#" title="' . esc_attr__('The title attribute in this link needs to be translatable', 'myplugin') . '">' . esc_html__('The anchor text also needs to be translatable', 'myplugin') . '</a>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
These examples are explained here: http://jamesc.id.au/2012/05/escape-translated-strings-wordpress-plugin-theme/