Ticket #6444: 6444.006.diff

File 6444.006.diff, 1.4 kB (added by markjaquith, 3 months ago)
  • wp-includes/shortcodes.php

    old new  
    7272        if (empty($shortcode_tags) || !is_array($shortcode_tags)) 
    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 
    8387function do_shortcode_tag($m) { 
  • wp-includes/formatting.php

    old new  
    9292        if (strpos($pee, '<pre') !== false) 
    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; 
    9798}