js_escape
Filter HookDescription
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.Hook Information
File Location |
wp-includes/formatting.php
View on GitHub
|
Hook Type | Filter |
Line Number | 4662 |
Hook Parameters
Type | Name | Description |
---|---|---|
string
|
$safe_text
|
The text after it has been escaped. |
string
|
$text
|
The text prior to being escaped. |
Usage Examples
Basic Usage
<?php
// Hook into js_escape
add_filter('js_escape', 'my_custom_filter', 10, 2);
function my_custom_filter($safe_text, $text) {
// Your custom filtering logic here
return $safe_text;
}
Source Code Context
wp-includes/formatting.php:4662
- How this hook is used in WordPress core
<?php
4657 * @since 2.0.6
4658 *
4659 * @param string $safe_text The text after it has been escaped.
4660 * @param string $text The text prior to being escaped.
4661 */
4662 return apply_filters( 'js_escape', $safe_text, $text );
4663 }
4664
4665 /**
4666 * Escaping for HTML blocks.
4667 *
PHP Documentation
<?php
/**
* 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.
*
* @since 2.0.6
*
* @param string $safe_text The text after it has been escaped.
* @param string $text The text prior to being escaped.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/formatting.php
Related Hooks
Related hooks will be displayed here in future updates.