Add single/double support to wp_specialchars(). Backported from trunk.

git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2006-07-06 02:31:06 +00:00
parent 74302dc057
commit 418ba348e8
1 changed files with 6 additions and 2 deletions

View File

@ -98,10 +98,14 @@ function seems_utf8($Str) { # by bmorel at ssi dot fr
function wp_specialchars( $text, $quotes = 0 ) {
// Like htmlspecialchars except don't double-encode HTML entities
$text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);-
$text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);
$text = str_replace('<', '&lt;', $text);
$text = str_replace('>', '&gt;', $text);
if ( $quotes ) {
if ( 'double' === $quotes ) {
$text = str_replace('"', '&quot;', $text);
} elseif ( 'single' === $quotes ) {
$text = str_replace("'", '&#039;', $text);
} elseif ( $quotes ) {
$text = str_replace('"', '&quot;', $text);
$text = str_replace("'", '&#039;', $text);
}