Changeset 30450 for branches/4.0/src/wp-includes/formatting.php
- Timestamp:
- 11/20/2014 02:29:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0/src/wp-includes/formatting.php
r29707 r30450 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 212 $comment_regex = 213 '!' // Start of comment, after the <. 214 . '(?:' // Unroll the loop: Consume everything until --> is found. 215 . '-(?!->)' // Dash not followed by end of comment. 216 . '[^\-]*+' // Consume non-dashes. 217 . ')*+' // Loop possessively. 218 . '-->'; // End of comment. 219 208 220 $regex = '/(' // Capture the entire match. 209 221 . '<' // Find start of element. 210 222 . '(?(?=!--)' // Is this a comment? 211 . '.+?--\s*>'// Find end of comment223 . $comment_regex // Find end of comment 212 224 . '|' 213 225 . '[^>]+>' // Find end of element … … 215 227 . '|' 216 228 . '\[' // Find start of shortcode. 217 . '\[?' // Shortcodes may begin with [[ 229 . '[\/\[]?' // Shortcodes may begin with [/ or [[ 230 . $tagregexp // Only match registered shortcodes, because performance. 218 231 . '(?:' 219 . '[^\[\]<>] ' // Shortcodes do not contain other shortcodes.232 . '[^\[\]<>]+' // Shortcodes do not contain other shortcodes. Quantifier critical. 220 233 . '|' 221 . '<[^ >]+>' // HTML elements permitted. Prevents matching ] before >.222 . ') ++'234 . '<[^\[\]>]*>' // HTML elements permitted. Prevents matching ] before >. 235 . ')*+' // Possessive critical. 223 236 . '\]' // Find end of shortcode. 224 237 . '\]?' // Shortcodes may end with ]] … … 242 255 continue; 243 256 244 } elseif ( '[' === $first && 1 === preg_match( '/^\[ (?:[^\[\]<>]|<[^>]+>)++\]$/', $curl ) ) {257 } elseif ( '[' === $first && 1 === preg_match( '/^\[\/?' . $tagregexp . '(?:[^\[\]<>]+|<[^\[\]>]*>)*+\]$/', $curl ) ) { 245 258 // This is a shortcode delimiter. 246 259 247 260 _wptexturize_pushpop_element( $curl, $no_texturize_shortcodes_stack, $no_texturize_shortcodes ); 248 261 249 } elseif ( '[' === $first && 1 === preg_match( '/^\[ \[?(?:[^\[\]<>]|<[^>]+>)++\]\]?$/', $curl ) ) {262 } elseif ( '[' === $first && 1 === preg_match( '/^\[[\/\[]?' . $tagregexp . '(?:[^\[\]<>]+|<[^\[\]>]*>)*+\]\]?$/', $curl ) ) { 250 263 // This is an escaped shortcode delimiter. 251 264
Note: See TracChangeset
for help on using the changeset viewer.