I am trying to develop a theme and trying to escape a string using esc_attr__() fuction. Here is how I implemented it.

$title = stoic_get_the_site_title();
echo esc_attr__($title, 'stoic');

But Themecheck plugin is giving me this error:

WARNING: Found a translation function that is missing a text-domain. Function esc_attr__, with the arguments 'stoic'

What is the proper way to do it so that Themecheck doesn't show this type of error?

  • contact the author of the plugin and tell him to improve his error messages. As for the question itself, this is like not doing any research at all, which is why the downvote. You just do not do such things, end of story. Aug 24 '17 at 7:01

If you have static text with dynamic content then you can use.

printf( esc_attr___('static text goes here with %s', 'text-domain' ), $title );

If you have only $title then no need to translate it.

Just escape it.

echo esc_attr( $title );

Note esc_attr, esc_attr__ and esc_attr_e used for escaping dynamic values from HTML element attributes.


`<div class="<?php echo esc_attr( $class ); ?>">`

And esc_html, esc_html__ and esc_html_e used for escaping dynamic values from HTML content.


<div> <?php echo esc_html( $title ); ?> </div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.