esc_js [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Escape single quotes, htmlspecialchar " < > &, and fix line endings.
Escapes text strings for echoing in JS. It is intended to be used for inline JS (in a tag attribute, for example onclick="..."). Note that the strings have to be in single quotes. The filter 'js_escape' is also applied here.
Source
<?php
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 ) );
$safe_text = str_replace( "\r", '', $safe_text );
$safe_text = str_replace( "\n", '\\n', addslashes( $safe_text ) );
return apply_filters( 'js_escape', $safe_text, $text );
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Data Validation « WordPress Codex
esc_attr( $text ) (since 2.8); esc_attr__(): Translates and encodes; esc_attr_e(): Translates, encodes, and echoes. JavaScript. esc_js( $text ) (since 2.8). URLs ...
codex.wordpress.org - esc_js (WordPress Function) - WPSeek.com
WordPress lookup for esc_js, a WordPress Function. wpseek.com is a WordPress -centric search tool for developers and theme authors.
wpseek.com - PHPXRef 0.7 : WordPress : Function Reference: esc_js()
Function and Method Cross Reference. esc_js(). Defined at: /wp-includes/ formatting.php -> line 2594. Referenced 25 times: /wp-includes/bookmark.php -> line ...
phpxref.ftwr.co.uk - esc_js | A HitchHackers guide through WordPress
Feb 11, 2011 ... Escapes text strings for echoing in JS. It is intended to be used for inline JS (in a tag attribute, for example onclick="…"). Note that the strings ...
hitchhackerguide.com