Changeset 29748 for trunk/src/wp-includes/formatting.php
- Timestamp:
- 09/17/2014 03:13:24 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r29715 r29748 29 29 */ 30 30 function wptexturize($text, $reset = false) { 31 global $wp_cockneyreplace ;31 global $wp_cockneyreplace, $shortcode_tags; 32 32 static $static_characters, $static_replacements, $dynamic_characters, $dynamic_replacements, 33 33 $default_no_texturize_tags, $default_no_texturize_shortcodes, $run_texturize = true; … … 206 206 // Look for shortcodes and HTML elements. 207 207 208 $tagnames = array_keys( $shortcode_tags ); 209 $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) ); 210 $tagregexp = "(?:$tagregexp)(?![\\w-])"; // Excerpt of get_shortcode_regex(). 211 208 212 $regex = '/(' // Capture the entire match. 209 213 . '<' // Find start of element. … … 216 220 . '\[' // Find start of shortcode. 217 221 . '\[?' // Shortcodes may begin with [[ 218 . '(?:' 219 . '[^\[\]<>]' // Shortcodes do not contain other shortcodes. 220 . '|' 221 . '<[^>]+>' // HTML elements permitted. Prevents matching ] before >. 222 . ')++' 222 . '\/?' // Closing slash may precede name. 223 . $tagregexp // Only match registered shortcodes, because performance. 224 . '[^\[\]]*' // Shortcodes do not contain other shortcodes. 223 225 . '\]' // Find end of shortcode. 224 226 . '\]?' // Shortcodes may end with ]] … … 242 244 continue; 243 245 244 } elseif ( '[' === $first && 1 === preg_match( '/^\[ (?:[^\[\]<>]|<[^>]+>)++\]$/', $curl ) ) {246 } elseif ( '[' === $first && 1 === preg_match( '/^\[\[?\/?' . $tagregexp . '[^\[\]]*\]\]?$/', $curl ) ) { 245 247 // This is a shortcode delimiter. 246 248 247 _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes );248 249 } elseif ( '[' === $first && 1 === preg_match( '/^\[\[?(?:[^\[\]<>]|<[^>]+>)++\]\]?$/', $curl ) ) {250 // This is an escaped shortcode delimiter.251 252 // Do not texturize.253 // Do not push to the shortcodes stack.254 255 continue;249 if ( '[[' !== substr( $curl, 0, 2 ) && ']]' !== substr( $curl, -2 ) ) { 250 // Looks like a normal shortcode. 251 _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); 252 } else { 253 // Looks like an escaped shortcode. 254 // Do not texturize. 255 // Do not push to the shortcodes stack. 256 continue; 257 } 256 258 257 259 } elseif ( empty( $no_texturize_shortcodes_stack ) && empty( $no_texturize_tags_stack ) ) { … … 314 316 // Parse out the tag name. 315 317 $space = strpos( $text, ' ' ); 316 if ( FALSE=== $space ) {318 if ( false === $space ) { 317 319 $space = -1; 318 320 } else {
Note: See TracChangeset
for help on using the changeset viewer.