WordPress at Your Fingertips

esc_attr_e() WP 2.8.0

Display translated text that has been escaped for safe use in an HTML tag attribute.

Escaping for HTML attributes. Converts <, >, &, ", ' characters to HTML entities. Does not make double escaping.

The function is used to escape the translation text, if the translation string value, for example, uses tags and the translated text that applied to the tag's attribute may cause display errors.

Encodes < > & " ' (less than, greater than, ampersand, double quote, single quote). Will never double encode entities.

If you need the value for use in PHP, use esc_attr__().

Uses: esc_attr()

No Hooks.

Return

null. Nothing.

Usage

esc_attr_e( $text, $domain );
$text(string) (required)
Text to translate.
$domain(string)
Text domain. Unique identifier for retrieving translated strings.
Default: 'default'

Examples

#1 Example from the default theme twentyeleven:

<a href="#secondary" title="<?php esc_attr_e( 'Skip to secondary content', 'twentyeleven' ); ?>">
	<?php _e( 'Skip to secondary content', 'twentyeleven' ); ?>
</a>

Changelog

Since 2.8.0 Introduced.

Code of esc_attr_e() WP 5.8.1

function esc_attr_e( $text, $domain = 'default' ) {
	echo esc_attr( translate( $text, $domain ) );
}

localize (l10n i18n Internationalization localization)

Localization

vladlu 100vlad.lu
Editors: Kama 100
No comments
    Log In