js_escape
Filters a string cleaned and escaped for output in JavaScript.
Text passed to esc_js() is stripped of invalid or special characters, and properly slashed for output.
Usage
add_filter( 'js_escape', 'wp_kama_js_escape_filter', 10, 2 ); /** * Function for `js_escape` filter-hook. * * @param string $safe_text The text after it has been escaped. * @param string $text The text prior to being escaped. * * @return string */ function wp_kama_js_escape_filter( $safe_text, $text ){ // filter... return $safe_text; }
- $safe_text(string)
- The text after it has been escaped.
- $text(string)
- The text prior to being escaped.
Changelog
Since 2.0.6 | Introduced. |
Where the hook is called
js_escape
wp-includes/formatting.php 4658
return apply_filters( 'js_escape', $safe_text, $text );