WordPress at a glance

esc_attr__() WP 2.8.0

Translates the text using esc_attr().

Encodes < > & " ' (greater than, less than, ampersand, double and single quotes) characters. Does not make double escaping.

Always use this function as a filter for form data (input):

<input type="text" value="<?php echo esc_attr__( 'Default value', 'textdomain' ) ?>">
Works based on: esc_attr()

No Hooks.

Return

String. Translated text on success, original text on failure.

Usage

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

Examples

#1 Title within the loop

<h2 class="entry-title">
	  <a href="<?php the_permalink(); ?>" 
			title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" 
			rel="bookmark"><?php the_title(); ?></a>
</h2>

Code of esc_attr__: wp-includes/l10n.php VER 4.9.8

<?php
function esc_attr__( $text, $domain = 'default' ) {
	return esc_attr( translate( $text, $domain ) );
}

Related Functions

From category: Localization

No comments
    Hello, !     Log In . Register