From ca6bd9ebd55c83a8f23237d995fbc3ff84865178 Mon Sep 17 00:00:00 2001
From: markjaquith )(.*?)
!is', 'clean_pre', $pee );
$pee = preg_replace( "|\n
\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone return $pee; } diff --git a/wp-includes/shortcodes.php b/wp-includes/shortcodes.php index 7803b3c527..907f7ff30a 100644 --- a/wp-includes/shortcodes.php +++ b/wp-includes/shortcodes.php @@ -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) {