Changeset 28986 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 07/04/2014 01:14:08 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/formatting.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r28973 r28986 97 97 $static_replacements = array_merge( array( '…', $opening_quote, $closing_quote, ' ™' ), $cockneyreplace ); 98 98 99 100 // Pattern-based replacements of characters. 101 // Sort the remaining patterns into several arrays for performance tuning. 102 $dynamic_characters = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); 103 $dynamic_replacements = array( 'apos' => array(), 'quote' => array(), 'dash' => array() ); 104 $dynamic = array(); 99 105 $spaces = wp_spaces_regexp(); 100 101 102 // Pattern-based replacements of characters.103 $dynamic = array();104 106 105 107 // '99' and '99" are ambiguous among other patterns; assume it's an abbreviated year at the end of a quotation. … … 116 118 } 117 119 118 // Quoted Numbers like "42" or '42.00' 119 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 120 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; 121 } 120 // Quoted Numbers like '0.42' 122 121 if ( "'" !== $opening_single_quote && "'" !== $closing_single_quote ) { 123 122 $dynamic[ '/(?<=\A|' . $spaces . ')\'(\d[.,\d]*)\'/' ] = $opening_single_quote . '$1' . $closing_single_quote; … … 134 133 } 135 134 135 // 9' (prime) 136 if ( "'" !== $prime ) { 137 $dynamic[ '/(?<=\d)\'/' ] = $prime; 138 } 139 140 // Single quotes followed by spaces or ending punctuation. 141 if ( "'" !== $closing_single_quote ) { 142 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 143 } 144 145 $dynamic_characters['apos'] = array_keys( $dynamic ); 146 $dynamic_replacements['apos'] = array_values( $dynamic ); 147 $dynamic = array(); 148 149 // Quoted Numbers like "42" 150 if ( '"' !== $opening_quote && '"' !== $closing_quote ) { 151 $dynamic[ '/(?<=\A|' . $spaces . ')"(\d[.,\d]*)"/' ] = $opening_quote . '$1' . $closing_quote; 152 } 153 136 154 // 9" (double prime) 137 155 if ( '"' !== $double_prime ) { … … 139 157 } 140 158 141 // 9' (prime)142 if ( "'" !== $prime ) {143 $dynamic[ '/(?<=\d)\'/' ] = $prime;144 }145 146 159 // Double quote at start, or preceded by (, {, <, [, -, or spaces, and not followed by spaces. 147 160 if ( '"' !== $opening_quote ) { … … 153 166 $dynamic[ '/"/' ] = $closing_quote; 154 167 } 155 156 // Single quotes followed by spaces or ending punctuation. 157 if ( "'" !== $closing_single_quote ) { 158 $dynamic[ '/\'(?=\Z|[.,)}\-\]]|>|' . $spaces . ')/' ] = $closing_single_quote; 159 } 160 168 169 $dynamic_characters['quote'] = array_keys( $dynamic ); 170 $dynamic_replacements['quote'] = array_values( $dynamic ); 171 $dynamic = array(); 172 161 173 // Dashes and spaces 162 174 $dynamic[ '/---/' ] = $em_dash; … … 165 177 $dynamic[ '/(?<=' . $spaces . ')-(?=' . $spaces . ')/' ] = $en_dash; 166 178 167 $dynamic_characters = array_keys( $dynamic );168 $dynamic_replacements = array_values( $dynamic );179 $dynamic_characters['dash'] = array_keys( $dynamic ); 180 $dynamic_replacements['dash'] = array_values( $dynamic ); 169 181 } 170 182 … … 238 250 239 251 $curl = str_replace( $static_characters, $static_replacements, $curl ); 240 $curl = preg_replace( $dynamic_characters, $dynamic_replacements, $curl ); 252 253 if ( false !== strpos( $curl, "'" ) ) { 254 $curl = preg_replace( $dynamic_characters['apos'], $dynamic_replacements['apos'], $curl ); 255 } 256 if ( false !== strpos( $curl, '"' ) ) { 257 $curl = preg_replace( $dynamic_characters['quote'], $dynamic_replacements['quote'], $curl ); 258 } 259 if ( false !== strpos( $curl, '-' ) ) { 260 $curl = preg_replace( $dynamic_characters['dash'], $dynamic_replacements['dash'], $curl ); 261 } 241 262 242 263 // 9x9 (times), but never 0x9999
Note: See TracChangeset
for help on using the changeset viewer.