Ticket #2059: 2059.diff

File 2059.diff, 1.1 KB (added by mdawaffe, 5 years ago)

uses preg_replace_callback() and modifies clean_pre()

  • wp-includes/formatting.php

     
    4444        return $output; 
    4545} 
    4646 
    47 function clean_pre($text) { 
     47// Accepts matches array from preg_replace_callback in wpautop() 
     48// or a string 
     49function clean_pre($matches) { 
     50        if ( is_array($matches) ) 
     51                $text = $matches[1] . $matches[2] . "</pre>"; 
     52        else 
     53                $text = $matches; 
     54 
    4855        $text = str_replace('<br />', '', $text); 
    4956        $text = str_replace('<p>', "\n", $text); 
    5057        $text = str_replace('</p>', '', $text); 
     58 
    5159        return $text; 
    5260} 
    5361 
     
    7886        $pee = preg_replace('!(</?' . $allblocks . '[^>]*>)\s*<br />!', "$1", $pee); 
    7987        $pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee); 
    8088        if (strpos($pee, '<pre') !== false) 
    81                 $pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' ", $pee); 
     89                $pee = preg_replace_callback('!(<pre.*?>)(.*?)</pre>!is', 'clean_pre', $pee ); 
    8290        $pee = preg_replace( "|\n</p>$|", '</p>', $pee ); 
    8391 
    8492        return $pee;