WordPress.org

Make WordPress Core

Changeset 11103


Ignore:
Timestamp:
04/27/09 21:58:04 (5 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/categories.php

    r10972 r11103  
    145145    <label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label> 
    146146    <input type="text" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 
    147     <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" /> 
     147    <input type="submit" value="<?php _ea( 'Search Categories' ); ?>" class="button" /> 
    148148</p> 
    149149</form> 
     
    185185<option value="delete"><?php _e('Delete'); ?></option> 
    186186</select> 
    187 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
     187<input type="submit" value="<?php _ea('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 
    188188<?php wp_nonce_field('bulk-categories'); ?> 
    189189</div> 
     
    225225<option value="delete"><?php _e('Delete'); ?></option> 
    226226</select> 
    227 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
     227<input type="submit" value="<?php _ea('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 
    228228<?php wp_nonce_field('bulk-categories'); ?> 
    229229</div> 
     
    279279</div> 
    280280 
    281 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p> 
     281<p class="submit"><input type="submit" class="button" name="submit" value="<?php _ea('Add Category'); ?>" /></p> 
    282282<?php do_action('edit_category_form', $category); ?> 
    283283</form></div> 
  • trunk/wp-includes/formatting.php

    r11098 r11103  
    20742074 * Escaping for HTML attributes. 
    20752075 * 
    2076  * @since 2.0.6 
     2076 * @since 2.8.0 
    20772077 * 
    20782078 * @param string $text 
    20792079 * @return string 
    20802080 */ 
    2081 function attribute_escape( $text ) { 
     2081function attr( $text ) { 
    20822082    $safe_text = wp_check_invalid_utf8( $text ); 
    20832083    $safe_text = wp_specialchars( $safe_text, ENT_QUOTES ); 
    20842084    return apply_filters( 'attribute_escape', $safe_text, $text ); 
     2085} 
     2086 
     2087/** 
     2088 * Escaping for HTML attributes. 
     2089 * 
     2090 * @since 2.0.6 
     2091 * 
     2092 * @deprecated 2.8.0 
     2093 * @see attr() 
     2094 *  
     2095 * @param string $text 
     2096 * @return string 
     2097 */ 
     2098function attribute_escape( $text ) { 
     2099    return attr( $text ); 
    20852100} 
    20862101 
  • 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.