Ticket #6969: wp6969_b.diff
| File wp6969_b.diff, 2.9 KB (added by , 17 years ago) |
|---|
-
wp-includes/shortcodes.php
170 170 * 171 171 * @return string The shortcode search regular expression 172 172 */ 173 function get_shortcode_regex( ) {173 function get_shortcode_regex($start = false) { 174 174 global $shortcode_tags; 175 175 $tagnames = array_keys($shortcode_tags); 176 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 177 178 return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 177 if ($start) { 178 return '\[('.$tagregexp.')\b'; 179 } else { 180 return '(.?)\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)'; 181 } 179 182 } 180 183 181 184 /** -
wp-includes/formatting.php
22 22 * 23 23 * @since 0.71 24 24 * @uses $wp_cockneyreplace Array of formatted entities for certain common phrases 25 * @uses get_shortcode_regex() Gets the search pattern for searching shortcodes. 25 26 * 26 27 * @param string $text The text to be formatted 27 28 * @return string The string replaced with html entities … … 32 33 $has_pre_parent = false; 33 34 $output = ''; 34 35 $curl = ''; 35 $textarr = preg_split('/(<.*>|\[.*\])/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE); 36 $shortcode_regex = get_shortcode_regex(); 37 preg_match_all("/$shortcode_regex/s", $text, $shortcode_matches, PREG_SET_ORDER); 38 // We must replace \2 with \3 from returned regexp since we are adding a capture. 39 $regex = '/(<[^>]*>|' . str_replace('\2', '\3', $shortcode_regex) . ')/s'; 40 $textarr = preg_split($regex, $text, -1, PREG_SPLIT_DELIM_CAPTURE); 36 41 $stop = count($textarr); 37 42 38 43 // if a plugin has provided an autocorrect array, use it … … 50 55 $dynamic_characters = array('/\'(\d\d(?:’|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/'); 51 56 $dynamic_replacements = array('’$1','$1‘', '$1″', '$1′', '$1’$2', '$1“$2', '”$1', '’$1', '$1×$2'); 52 57 58 $skip_count = 0; 59 $shortcode_start_regex = "/^" . get_shortcode_regex(true) . "/"; 60 $shortcode_idx = 0; 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 = count($shortcode_matches[$shortcode_idx++]) - 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