Don't wpautop()-wrap shortcodes that stand alone. fixes #6444 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@7815 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith
2008-04-25 00:45:31 +00:00
parent 24a68a43b4
commit 1c68bb873d
2 changed files with 8 additions and 3 deletions
+7 -3
View File
@@ -72,12 +72,16 @@ function do_shortcode($content) {
if (empty($shortcode_tags) || !is_array($shortcode_tags))
return $content;
$pattern = get_shortcode_regex();
return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
}
function get_shortcode_regex() {
global $shortcode_tags;
$tagnames = array_keys($shortcode_tags);
$tagregexp = join( '|', array_map('preg_quote', $tagnames) );
$pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';
return preg_replace_callback($pattern, 'do_shortcode_tag', $content);
return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';
}
function do_shortcode_tag($m) {