attr(), _a(), _ea(), _xa() for shorthand attribute escaping. see #9650
git-svn-id: http://svn.automattic.com/wordpress/trunk@11103 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8cd2e92b69
commit
2249c69021
|
@ -144,7 +144,7 @@ endif; ?>
|
||||||
<p class="search-box">
|
<p class="search-box">
|
||||||
<label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
|
<label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
|
||||||
<input type="text" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
|
<input type="text" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
|
||||||
<input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
|
<input type="submit" value="<?php _ea( 'Search Categories' ); ?>" class="button" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
@ -184,7 +184,7 @@ if ( $page_links )
|
||||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||||
<option value="delete"><?php _e('Delete'); ?></option>
|
<option value="delete"><?php _e('Delete'); ?></option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
<input type="submit" value="<?php _ea('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
|
||||||
<?php wp_nonce_field('bulk-categories'); ?>
|
<?php wp_nonce_field('bulk-categories'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ if ( $page_links )
|
||||||
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
<option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
|
||||||
<option value="delete"><?php _e('Delete'); ?></option>
|
<option value="delete"><?php _e('Delete'); ?></option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
<input type="submit" value="<?php _ea('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||||
<?php wp_nonce_field('bulk-categories'); ?>
|
<?php wp_nonce_field('bulk-categories'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ if ( $page_links )
|
||||||
<p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
|
<p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
|
<p class="submit"><input type="submit" class="button" name="submit" value="<?php _ea('Add Category'); ?>" /></p>
|
||||||
<?php do_action('edit_category_form', $category); ?>
|
<?php do_action('edit_category_form', $category); ?>
|
||||||
</form></div>
|
</form></div>
|
||||||
|
|
||||||
|
|
|
@ -2070,18 +2070,33 @@ function js_escape($text) {
|
||||||
return apply_filters( 'js_escape', $safe_text, $text );
|
return apply_filters( 'js_escape', $safe_text, $text );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escaping for HTML attributes.
|
||||||
|
*
|
||||||
|
* @since 2.8.0
|
||||||
|
*
|
||||||
|
* @param string $text
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function attr( $text ) {
|
||||||
|
$safe_text = wp_check_invalid_utf8( $text );
|
||||||
|
$safe_text = wp_specialchars( $safe_text, ENT_QUOTES );
|
||||||
|
return apply_filters( 'attribute_escape', $safe_text, $text );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Escaping for HTML attributes.
|
* Escaping for HTML attributes.
|
||||||
*
|
*
|
||||||
* @since 2.0.6
|
* @since 2.0.6
|
||||||
*
|
*
|
||||||
|
* @deprecated 2.8.0
|
||||||
|
* @see attr()
|
||||||
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function attribute_escape( $text ) {
|
function attribute_escape( $text ) {
|
||||||
$safe_text = wp_check_invalid_utf8( $text );
|
return attr( $text );
|
||||||
$safe_text = wp_specialchars( $safe_text, ENT_QUOTES );
|
|
||||||
return apply_filters( 'attribute_escape', $safe_text, $text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -105,6 +105,22 @@ function __( $text, $domain = 'default' ) {
|
||||||
return translate( $text, $domain );
|
return translate( $text, $domain );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the translation of $text and escapes it for safe use in an attribute.
|
||||||
|
* If there is no translation, or the domain isn't loaded the original text is returned.
|
||||||
|
*
|
||||||
|
* @see translate() An alias of translate()
|
||||||
|
* @see attr()
|
||||||
|
* @since 2.8.0
|
||||||
|
*
|
||||||
|
* @param string $text Text to translate
|
||||||
|
* @param string $domain Optional. Domain to retrieve the translated text
|
||||||
|
* @return string Translated text
|
||||||
|
*/
|
||||||
|
function _a( $text, $domain = 'default' ) {
|
||||||
|
return attr( translate( $text, $domain ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the returned translated text from translate().
|
* Displays the returned translated text from translate().
|
||||||
*
|
*
|
||||||
|
@ -118,6 +134,20 @@ function _e( $text, $domain = 'default' ) {
|
||||||
echo translate( $text, $domain );
|
echo translate( $text, $domain );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays translated text that has been escaped for safe use in an attribute.
|
||||||
|
*
|
||||||
|
* @see translate() Echos returned translate() string
|
||||||
|
* @see attr()
|
||||||
|
* @since 2.8.0
|
||||||
|
*
|
||||||
|
* @param string $text Text to translate
|
||||||
|
* @param string $domain Optional. Domain to retrieve the translated text
|
||||||
|
*/
|
||||||
|
function _ea( $text, $domain = 'default' ) {
|
||||||
|
echo attr( translate( $text, $domain ) );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve translated string with vertical bar context
|
* Retrieve translated string with vertical bar context
|
||||||
*
|
*
|
||||||
|
@ -145,6 +175,10 @@ function _x( $single, $context, $domain = 'default' ) {
|
||||||
return translate_with_gettext_context( $single, $context, $domain );
|
return translate_with_gettext_context( $single, $context, $domain );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _xa( $single, $context, $domain = 'default' ) {
|
||||||
|
return attr( translate_with_gettext_context( $single, $context, $domain ) );
|
||||||
|
}
|
||||||
|
|
||||||
function __ngettext() {
|
function __ngettext() {
|
||||||
_deprecated_function( __FUNCTION__, '2.8', '_n()' );
|
_deprecated_function( __FUNCTION__, '2.8', '_n()' );
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
Loading…
Reference in New Issue