Ticket #11257: ticket-11257-v3.patch
File ticket-11257-v3.patch, 2.8 KB (added by , 14 years ago) |
---|
-
formatting.php
173 173 * or 'false'. 174 174 * 175 175 * @since 0.71 176 * @uses $shortcode_tags 176 177 * 177 178 * @param string $pee The text which has to be formatted. 178 179 * @param int|bool $br Optional. If set, this will convert all remaining line-breaks after paragraphing. Default true. 179 180 * @return string Text which has been converted into correct paragraph tags. 180 181 */ 181 182 function wpautop($pee, $br = 1) { 183 global $shortcode_tags; 184 182 185 if ( trim($pee) === '' ) 183 186 return ''; 184 187 $pee = $pee . "\n"; // just to make things a little easier, pad the end … … 216 219 if (strpos($pee, '<pre') !== false) 217 220 $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee ); 218 221 $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 219 $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone220 222 223 // don't auto-p wrap shortcodes that stand alone 224 $tagnames = array_keys($shortcode_tags); 225 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 226 $pee = preg_replace('/<p>\\s*?(.?\\[('.$tagregexp.')\\b.*?\\/?\\](?:.+?\\[\\/\\2\\])?.?)\\s*<\\/p>/s', '$1', $pee); 227 221 228 return $pee; 222 229 } 223 230 -
shortcodes.php
176 176 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 177 177 178 178 // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes() 179 return '(.?)\ [('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';179 return '(.?)\\[('.$tagregexp.')\\b(.*?)\\/?\\](?:(.+?)\\[\\/\\2\\])?(.?)'; 180 180 } 181 181 182 182 /** … … 194 194 global $shortcode_tags; 195 195 196 196 // allow [[foo]] syntax for escaping a tag 197 if ($m[1] == '[' && $m[ 6] == ']') {197 if ($m[1] == '[' && $m[5] == ']') { 198 198 return substr($m[0], 1, -1); 199 199 } 200 200 201 201 $tag = $m[2]; 202 202 $attr = shortcode_parse_atts($m[3]); 203 203 204 if ( isset($m[ 5]) ) {204 if ( isset($m[4]) ) { 205 205 // enclosing tag - extra parameter 206 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[ 5], $m[2]) . $m[6];206 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[4], $m[2]) . $m[5]; 207 207 } else { 208 208 // self-closing tag 209 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, NULL, $m[2]) . $m[ 6];209 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, NULL, $m[2]) . $m[5]; 210 210 } 211 211 } 212 212 … … 290 290 291 291 $pattern = get_shortcode_regex(); 292 292 293 return preg_replace('/'.$pattern.'/s', '$1$ 6', $content);293 return preg_replace('/'.$pattern.'/s', '$1$5', $content); 294 294 } 295 295 296 296 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() 297 297 298 ?> 299 No newline at end of file 298 ?>