Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




esc_js [ WordPress Function ]

esc_js ( $text )
Parameters:
  • (string) $text The text to be escaped.
Returns:
  • (string) Escaped text.
Defined at:

Benzer Fonksiyonlar: esc_sql, esc_url, esc_html, esc_attr, fetch_rss


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_textENT_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ý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics