Make WordPress Core


Ignore:
Timestamp:
04/27/2009 09:58:04 PM (16 years ago)
Author:
ryan
Message:

attr(), _a(), _ea(), _xa() for shorthand attribute escaping. see #9650

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/l10n.php

    r11083 r11103  
    107107
    108108/**
     109 * Retrieves the translation of $text and escapes it for safe use in an attribute.
     110 * If there is no translation, or the domain isn't loaded the original text is returned.
     111 *
     112 * @see translate() An alias of translate()
     113 * @see attr()
     114 * @since 2.8.0
     115 *
     116 * @param string $text Text to translate
     117 * @param string $domain Optional. Domain to retrieve the translated text
     118 * @return string Translated text
     119 */
     120function _a( $text, $domain = 'default' ) {
     121    return attr( translate( $text, $domain ) );
     122}
     123
     124/**
    109125 * Displays the returned translated text from translate().
    110126 *
     
    117133function _e( $text, $domain = 'default' ) {
    118134    echo translate( $text, $domain );
     135}
     136
     137/**
     138 * Displays translated text that has been escaped for safe use in an attribute.
     139 *
     140 * @see translate() Echos returned translate() string
     141 * @see attr()
     142 * @since 2.8.0
     143 *
     144 * @param string $text Text to translate
     145 * @param string $domain Optional. Domain to retrieve the translated text
     146 */
     147function _ea( $text, $domain = 'default' ) {
     148    echo attr( translate( $text, $domain ) );
    119149}
    120150
     
    144174function _x( $single, $context, $domain = 'default' ) {
    145175    return translate_with_gettext_context( $single, $context, $domain );
     176}
     177
     178function _xa( $single, $context, $domain = 'default' ) {
     179    return attr( translate_with_gettext_context( $single, $context, $domain ) );
    146180}
    147181
Note: See TracChangeset for help on using the changeset viewer.