I would like to separate the Welcome to %s and Thanks for creating account on %1$s by making each appear in a separate row.
They are currently jammed together/messed up when translating the phrases on a RTL site.
protected function send_account_email( $user_data, $user_id ) {
$to = $user_data['user_email'];
$subject = sprintf( esc_html__( 'Welcome to %s', 'my-plugin' ), get_option( 'blogname' ) );
$body = sprintf( esc_html__( 'Thanks for creating account on %1$s. Your username is: %2$s ',
'my-plugin' ), get_option( 'blogname' ), $user_data['user_login'] );
}
You need a "line break" to separate them out! You could use
htmltags such as:brtagptagh1tagJust to name a few!
BUT you're using
esc_html__to translate AND escapehtml. Why do you need to useesc_html__to retrieve the name of your blog from your database? Why?That being said, there is a whitelisting technique you could use to
translateandescape unwanted htmlat the same time.Using
wp_ksesyou would be able to define a "white-list" for allowedhtmltags and escape the rest of them.You could read more about it:
and
So your code would be something like this:
Using
<br>tag:OR using
<p>tag:OR using
<h1>tag:Note:
$whitelist_tagsis an array, so you could add multiple tags to it!$subjectvariable, you could use the exact technique in your$bodyvariable too, if you need to!__()with combination ofwp_ksesinstead ofesc_html__in order totranslateANDescape unwanted html!