Changeset 28762 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 06/17/2014 05:56:08 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r28761 r28762 25 25 * 26 26 * @param string $text The text to be formatted 27 * @param bool $reset Set to true for unit testing. Translated patterns will reset. 27 28 * @return string The string replaced with html entities 28 29 */ 29 function wptexturize($text ) {30 function wptexturize($text, $reset = false) { 30 31 global $wp_cockneyreplace; 31 32 static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements, 32 33 $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true; 33 34 34 if ( false === $run_texturize ) { 35 // If there's nothing to do, just stop. 36 if ( empty( $text ) || false === $run_texturize ) { 35 37 return $text; 36 38 } 37 39 38 // No need to set up these static variables more than once39 if ( ! isset( $static_characters ) ) {40 // Set up static variables. Run once only. 41 if ( $reset || ! isset( $static_characters ) ) { 40 42 /** 41 43 * Filter whether to skip running `wptexturize()`. … … 124 126 } 125 127 126 // Apostrophe in a word. No spaces or double apostrophes.128 // Apostrophe in a word. No spaces, double apostrophes, or other punctuation. 127 129 if ( "'" != $apos ) { 128 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z| \'|' . $spaces . ')/' ] = $apos;130 $dynamic[ '/(?<!' . $spaces . ')\'(?!\Z|[.,:;"\'(){}<>[\]\-]|' . $spaces . ')/' ] = $apos; 129 131 } 130 132 … … 149 151 } 150 152 151 // Single quotes followed by spaces or a period.152 if ( "'" != =$closing_single_quote ) {153 $dynamic[ '/\'(?=\Z| \.|' . $spaces . ')/' ] = $closing_single_quote;153 // Single quotes followed by spaces or ending punctuation. 154 if ( "'" != $closing_single_quote ) { 155 $dynamic[ '/\'(?=\Z|[.,)}>\-\]]|' . $spaces . ')/' ] = $closing_single_quote; 154 156 } 155 157 … … 162 164 $dynamic_characters = array_keys( $dynamic ); 163 165 $dynamic_replacements = array_values( $dynamic ); 164 }165 166 // If there's nothing to do, just stop.167 if ( empty( $text ) ) {168 return $text;169 166 } 170 167
Note: See TracChangeset
for help on using the changeset viewer.