Make WordPress Core

Changeset 7816


Ignore:
Timestamp:
04/25/2008 12:46:17 AM (17 years ago)
Author:
markjaquith
Message:

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

Location:
branches/2.5/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.5/wp-includes/formatting.php

    r7811 r7816  
    9393        $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee );
    9494    $pee = preg_replace( "|\n</p>$|", '</p>', $pee );
     95    $pee = preg_replace('/<p>\s*?(' . get_shortcode_regex() . ')\s*<\/p>/s', '$1', $pee); // don't auto-p wrap shortcodes that stand alone
    9596
    9697    return $pee;
  • branches/2.5/wp-includes/shortcodes.php

    r7811 r7816  
    7373        return $content;
    7474
     75    $pattern = get_shortcode_regex();
     76    return preg_replace_callback('/'.$pattern.'/s', 'do_shortcode_tag', $content);
     77}
     78
     79function get_shortcode_regex() {
     80    global $shortcode_tags;
    7581    $tagnames = array_keys($shortcode_tags);
    7682    $tagregexp = join( '|', array_map('preg_quote', $tagnames) );
    7783
    78     $pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s';
    79 
    80     return preg_replace_callback($pattern, 'do_shortcode_tag', $content);
     84    return '\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?';
    8185}
    8286
Note: See TracChangeset for help on using the changeset viewer.