esc_js(). Shorter, follows new escaping naming convention.

git-svn-id: https://develop.svn.wordpress.org/trunk@11245 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2009-05-09 07:27:22 +00:00
parent 90ef467838
commit 8d6cb67233
19 changed files with 52 additions and 35 deletions
+19 -2
View File
@@ -2054,12 +2054,12 @@ function htmlentities2($myHTML) {
*
* The filter 'js_escape' is also applied here.
*
* @since 2.0.4
* @since 2.8.0
*
* @param string $text The text to be escaped.
* @return string Escaped text.
*/
function js_escape($text) {
function esc_js( $text ) {
$safe_text = wp_check_invalid_utf8( $text );
$safe_text = wp_specialchars( $safe_text, ENT_COMPAT );
$safe_text = preg_replace( '/&#(x)?0*(?(1)27|39);?/i', "'", stripslashes( $safe_text ) );
@@ -2067,6 +2067,23 @@ function js_escape($text) {
return apply_filters( 'js_escape', $safe_text, $text );
}
/**
* Escape single quotes, specialchar double quotes, and fix line endings.
*
* The filter 'js_escape' is also applied by esc_js()
*
* @since 2.0.4
*
* @deprecated 2.8.0
* @see esc_js()
*
* @param string $text The text to be escaped.
* @return string Escaped text.
*/
function js_escape( $text ) {
return esc_js( $text );
}
/**
* Escaping for HTML attributes.
*