Ticket #11257: ticket-11257-v2.patch
File ticket-11257-v2.patch, 2.6 KB (added by , 15 years ago) |
---|
-
wp-includes/formatting.php
216 216 if (strpos($pee, '<pre') !== false) 217 217 $pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee ); 218 218 $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 alone219 $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex(1) . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone 220 220 221 221 return $pee; 222 222 } -
wp-includes/shortcodes.php
168 168 * @since 2.5 169 169 * @uses $shortcode_tags 170 170 * 171 * @param int Backreference nesting context for this regexp. 171 172 * @return string The shortcode search regular expression 172 173 */ 173 function get_shortcode_regex( ) {174 function get_shortcode_regex($nesting = 0) { 174 175 global $shortcode_tags; 175 176 $tagnames = array_keys($shortcode_tags); 176 177 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 177 178 179 $backref = 2 + (int) $nesting; 180 178 181 // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcodes() 179 return '(.?)\ [('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)';182 return '(.?)\\[('.$tagregexp.')\\b(.*?)\\/?\\](?:(.+?)\\[\\/\\'.$backref.'\\])?(.?)'; 180 183 } 181 184 182 185 /** … … 194 197 global $shortcode_tags; 195 198 196 199 // allow [[foo]] syntax for escaping a tag 197 if ($m[1] == '[' && $m[ 6] == ']') {200 if ($m[1] == '[' && $m[5] == ']') { 198 201 return substr($m[0], 1, -1); 199 202 } 200 203 201 204 $tag = $m[2]; 202 205 $attr = shortcode_parse_atts($m[3]); 203 206 204 if ( isset($m[ 5]) ) {207 if ( isset($m[4]) ) { 205 208 // enclosing tag - extra parameter 206 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[ 5], $m[2]) . $m[6];209 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, $m[4], $m[2]) . $m[5]; 207 210 } else { 208 211 // self-closing tag 209 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, NULL, $m[2]) . $m[ 6];212 return $m[1] . call_user_func($shortcode_tags[$tag], $attr, NULL, $m[2]) . $m[5]; 210 213 } 211 214 } 212 215 … … 290 293 291 294 $pattern = get_shortcode_regex(); 292 295 293 return preg_replace('/'.$pattern.'/s', '$1$ 6', $content);296 return preg_replace('/'.$pattern.'/s', '$1$5', $content); 294 297 } 295 298 296 299 add_filter('the_content', 'do_shortcode', 11); // AFTER wpautop() 297 300 298 ?> 299 No newline at end of file 301 ?>