Warning: This function has been deprecated. Use esc_js() instead.

js_escape() WordPress Function

The js_escape() function is used to escape JavaScript strings. This is necessary to prevent JavaScript injection attacks. The function takes a string as an argument and returns the escaped string.

js_escape( string $text ) #

Escape single quotes, specialchar double quotes, and fix line endings.


Description

The filter ‘js_escape’ is also applied by esc_js().

Top ↑

See also


Top ↑

Parameters

$text

(string)(Required)The text to be escaped.


Top ↑

Return

(string) Escaped text.


Top ↑

Source

File: wp-includes/deprecated.php

function js_escape( $text ) {
	_deprecated_function( __FUNCTION__, '2.8.0', 'esc_js()' );
	return esc_js( $text );
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Use esc_js()
2.0.4Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More