js_escape WordPress Filter Hook

The js_escape hook is a great way to ensure that your JavaScript code is properly escaped before it is output to the browser. This hook will take your code and escape any special characters, making it safe to output to the browser.

apply_filters( 'js_escape', string $safe_text, string $text ) #

Filters a string cleaned and escaped for output in JavaScript.


Description

Text passed to esc_js() is stripped of invalid or special characters, and properly slashed for output.


Top ↑

Parameters

$safe_text

(string)The text after it has been escaped.

$text

(string)The text prior to being escaped.


Top ↑

Source

File: wp-includes/formatting.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
2.0.6Introduced.

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