Ticket #6969: wp6969_c.diff
| File wp6969_c.diff, 1.9 KB (added by , 17 years ago) |
|---|
-
wp-includes/formatting.php
28 28 */ 29 29 function wptexturize($text) { 30 30 global $wp_cockneyreplace; 31 global $shortcode_tags; 32 31 33 $next = true; 32 34 $has_pre_parent = false; 33 35 $output = ''; 34 36 $curl = ''; 35 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);36 $stop = count($textarr);37 37 38 $tagnames = array_keys($shortcode_tags); 39 $tagregexp = join('|', array_map('preg_quote', $tagnames)); 40 $regex = '/(<[^>]*>|(?<!\[)\[('.$tagregexp.')\b[^\/\]]*\/?\](?:.+?\[\/\2\])?)/s'; 41 $textarr = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE); 42 $stop = count($textarr); 43 38 44 // if a plugin has provided an autocorrect array, use it 39 45 if ( isset($wp_cockneyreplace) ) { 40 46 $cockney = array_keys($wp_cockneyreplace); … … 50 56 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); 51 57 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); 52 58 59 $skip_count = 0; 60 $shortcode_start_regex = '/^\[(?:'.$tagregexp.')\b/'; 53 61 for ( $i = 0; $i < $stop; $i++ ) { 54 62 $curl = $textarr[$i]; 55 63 56 if ( !empty($curl) && '<' != $curl{0} && '[' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag 64 if ($skip_count > 0) { 65 $skip_count--; 66 continue; 67 } elseif (empty($curl)) { 68 $next = true; 69 continue; 70 } elseif (preg_match($shortcode_start_regex, ltrim($curl))) { //shortcode 71 $skip_count = 1; 72 } elseif ('<' != $curl{0} && $next && !$has_pre_parent) { // If it's not a tag 57 73 // static strings 58 74 $curl = str_replace($static_characters, $static_replacements, $curl); 59 75 // regular expressions