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:
parent
24a68a43b4
commit
1c68bb873d
@ -92,6 +92,7 @@ function wpautop($pee, $br = 1) {
|
||||
if (strpos($pee, '<pre') !== false)
|
||||
$pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );
|
||||
$pee = preg_replace( "|\n</p>$|", '</p>', $pee );
|
||||
$pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
|
||||
|
||||
return $pee;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user