Make WordPress Core


Ignore:
Timestamp:
07/06/2006 02:31:06 AM (19 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.