I am using “add_settings_field” and want to provide translation for it , but my problem is security.
So is __('My Checbox:' , 'domain')
secure enough for translation?
If not what can I do about it?
I have tried to use esc_html_e( 'My Checbox:' , 'domain' )
and esc_html_( 'My Checbox:' , 'domain' )
but it breaks my page…
add_settings_field(
'add_checkbox',
__('My Checbox:' , 'domain'),<!--Is this secure when translating?-->
'my_checkbox_function',
'theme_options',
'theme_options'
);
No, it is not. Use
esc_html__( 'string', 'text_domain' )
instead (two underscores).Translated strings are unknown input. Unknown input is per default malicious.
Always make your output as safe as possible. If you don’t want HTML in a string, do not allow it. If you get errors, analyze the error messages and fix those errors, do not loose up security.