Add js_escape and attribute_escape filters.

git-svn-id: http://svn.automattic.com/wordpress/trunk@4660 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-12-22 05:26:43 +00:00
parent dc17d069c0
commit f2665b2cb2

View File

@ -1076,14 +1076,16 @@ function htmlentities2($myHTML) {
// Escape single quotes, specialchar double quotes, and fix line endings.
function js_escape($text) {
$text = wp_specialchars($text, 'double');
$text = str_replace(''', "'", $text);
return preg_replace("/\r?\n/", "\\n", addslashes($text));
$safe_text = wp_specialchars($text, 'double');
$safe_text = str_replace(''', "'", $safe_text);
$safe_text = preg_replace("/\r?\n/", "\\n", addslashes($safe_text));
return apply_filters('js_escape', $safe_text, $text);
}
// Escaping for HTML attributes
function attribute_escape($text) {
return wp_specialchars($text, true);
$safe_text = wp_specialchars($text, true);
return apply_filters('attribute_escape', $safe_text, $text);
}
function wp_make_link_relative( $link ) {