Changeset 3996

Show
Ignore:
Timestamp:
07/06/06 02:31:06 (3 years ago)
Author:
ryan
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2.0/wp-includes/functions-formatting.php

    r3964 r3996  
    9999function wp_specialchars( $text, $quotes = 0 ) { 
    100100    // Like htmlspecialchars except don't double-encode HTML entities 
    101     $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text);- 
     101    $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&$1', $text); 
    102102    $text = str_replace('<', '&lt;', $text); 
    103103    $text = str_replace('>', '&gt;', $text); 
    104     if ( $quotes ) { 
     104    if ( 'double' === $quotes ) { 
     105        $text = str_replace('"', '&quot;', $text); 
     106    } elseif ( 'single' === $quotes ) { 
     107        $text = str_replace("'", '&#039;', $text); 
     108    } elseif ( $quotes ) { 
    105109        $text = str_replace('"', '&quot;', $text); 
    106110        $text = str_replace("'", '&#039;', $text);