WordPress.org

Make WordPress Core

Changeset 7815


Ignore:
Timestamp:
04/25/08 00:45:31 (7 years ago)
Author:
markjaquith
Message:

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

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r7814 r7815  
    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; 
  • trunk/wp-includes/shortcodes.php

    r7814 r7815  
    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.