Changeset 19795
- Timestamp:
- 01/31/2012 02:06:32 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r19712 r19795 29 29 function wptexturize($text) { 30 30 global $wp_cockneyreplace; 31 static $opening_quote, $closing_quote, $en_dash, $em_dash, $default_no_texturize_tags, $default_no_texturize_shortcodes, $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 31 static $opening_quote, $closing_quote, $opening_single_quote, $closing_single_quote, $en_dash, $em_dash, 32 $apos, $prime, $double_prime, $default_no_texturize_tags, $default_no_texturize_shortcodes, 33 $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements; 32 34 33 35 // No need to set up these static variables more than once 34 36 if ( empty( $opening_quote ) ) { 35 /* translators: opening curly quote */ 36 $opening_quote = _x('“', 'opening curly quote'); 37 /* translators: closing curly quote */ 38 $closing_quote = _x('”', 'closing curly quote'); 37 /* translators: opening curly double quote */ 38 $opening_quote = _x( '“', 'opening curly double quote' ); 39 /* translators: closing curly double quote */ 40 $closing_quote = _x( '”', 'closing curly double quote' ); 41 42 /* translators: apostrophe, for example in 'cause or can't */ 43 $apos = _x( '’', 'apostrophe' ); 44 45 /* translators: prime, for example in 9' (nine feet) */ 46 $prime = _x( '′', 'prime' ); 47 /* translators: double prime, for example in 9" (nine inches) */ 48 $double_prime = _x( '″', 'double prime' ); 49 50 /* translators: opening curly single quote */ 51 $opening_single_quote = _x( '‘', 'opening curly single quote' ); 52 /* translators: closing curly single quote */ 53 $closing_single_quote = _x( '’', 'closing curly single quote' ); 54 39 55 /* translators: en dash */ 40 $en_dash = _x( '–', 'en dash');56 $en_dash = _x( '–', 'en dash' ); 41 57 /* translators: em dash */ 42 $em_dash = _x( '—', 'em dash');58 $em_dash = _x( '—', 'em dash' ); 43 59 44 60 $default_no_texturize_tags = array('pre', 'code', 'kbd', 'style', 'script', 'tt'); … … 49 65 $cockney = array_keys($wp_cockneyreplace); 50 66 $cockneyreplace = array_values($wp_cockneyreplace); 67 } elseif ( "'" != $apos ) { // Only bother if we're doing a replacement. 68 $cockney = array( "'tain't", "'twere", "'twas", "'tis", "'twill", "'til", "'bout", "'nuff", "'round", "'cause" ); 69 $cockneyreplace = array( $apos . "tain" . $apos . "t", $apos . "twere", $apos . "twas", $apos . "tis", $apos . "twill", $apos . "til", $apos . "bout", $apos . "nuff", $apos . "round", $apos . "cause" ); 51 70 } else { 52 $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause"); 53 $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’cause"); 71 $cockney = $cockneyreplace = array(); 54 72 } 55 73 56 $static_characters = array_merge( array('---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)'), $cockney ); 57 $static_replacements = array_merge( array($em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™'), $cockneyreplace ); 58 59 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/\'(\d)/', '/(\s|\A|[([{<]|")\'/', '/(\d)"/', '/(\d)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A|[([{<])"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/\b(\d+)x(\d+)\b/'); 60 $dynamic_replacements = array('’$1','’$1', '$1‘', '$1″', '$1′', '$1’$2', '$1' . $opening_quote . '$2', $closing_quote . '$1', '’$1', '$1×$2'); 74 $static_characters = array_merge( array( '---', ' -- ', '--', ' - ', 'xn–', '...', '``', '\'\'', ' (tm)' ), $cockney ); 75 $static_replacements = array_merge( array( $em_dash, ' ' . $em_dash . ' ', $en_dash, ' ' . $en_dash . ' ', 'xn--', '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 76 77 $dynamic = array(); 78 if ( "'" != $apos ) { 79 $dynamic[ '/\'(\d\d(?:’|\')?s)/' ] = $apos . '$1'; // '99's 80 $dynamic[ '/\'(\d)/' ] = $apos . '$1'; // '99 81 } 82 if ( "'" != $opening_single_quote ) 83 $dynamic[ '/(\s|\A|[([{<]|")\'/' ] = '$1' . $opening_single_quote; // opening single quote, even after (, {, <, [ 84 if ( '"' != $double_prime ) 85 $dynamic[ '/(\d)"/' ] = '$1' . $double_prime; // 9" (double prime) 86 if ( "'" != $prime ) 87 $dynamic[ '/(\d)\'/' ] = '$1' . $prime; // 9' (prime) 88 if ( "'" != $apos ) 89 $dynamic[ '/(\S)\'([^\'\s])/' ] = '$1' . $apos . '$2'; // apostrophe in a word 90 if ( '"' != $opening_quote ) 91 $dynamic[ '/(\s|\A|[([{<])"(?!\s)/' ] = '$1' . $opening_quote . '$2'; // opening double quote, even after (, {, <, [ 92 if ( '"' != $closing_quote ) 93 $dynamic[ '/"(\s|\S|\Z)/' ] = $closing_quote . '$1'; // closing double quote 94 if ( "'" != $closing_single_quote ) 95 $dynamic[ '/\'([\s.]|\Z)/' ] = $closing_single_quote . '$2'; // closing single quote 96 97 $dynamic[ '/\b(\d+)x(\d+)\b/' ] = '$1×$2'; // 9x9 (times) 98 99 $dynamic_characters = array_keys( $dynamic ); 100 $dynamic_replacements = array_values( $dynamic ); 61 101 } 62 102
Note: See TracChangeset
for help on using the changeset viewer.