Ticket #5678: 5678.r6625.diff

File 5678.r6625.diff, 1.5 KB (added by hansengel, 5 years ago)

Fixes #5678 in r6625 (credit jdub if this is committed, please)

  • wp-includes/formatting.php

     
    12571257        return $matches[0]; 
    12581258} 
    12591259 
     1260// Respectfully strip unnecessary newlines 
     1261function strip_newlines($text) { 
     1262        $textarr = preg_split("/(<[^>]+>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE); 
     1263        $stop = count($textarr); $skip = false; $output = ''; // loop stuff 
     1264        for ($ci = 0; $ci < $stop; $ci++) { 
     1265                $curl = $textarr[$ci]; 
     1266                if (! $skip && isset($curl{0}) && '<' != $curl{0}) { // If it's not a tag 
     1267                        $curl = preg_replace('/[\n\r]+/', ' ', $curl); 
     1268                } elseif (strpos($curl, '<code') !== false || strpos($curl, '<pre') !== false || strpos($curl, '<kbd') !== false || strpos($curl, '<style') !== false || strpos($curl, '<script') !== false) { 
     1269                        $next = false; 
     1270                } else { 
     1271                        $next = true; 
     1272                } 
     1273                $output .= $curl; 
     1274        } 
     1275        return $output; 
     1276} 
     1277 
    12601278?> 
  • wp-admin/import/rss.php

     
    9090                        $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
    9191                        $post_content = str_replace('<br>', '<br />', $post_content); 
    9292                        $post_content = str_replace('<hr>', '<hr />', $post_content); 
     93                        $post_content = strip_newlines($post_content); 
    9394 
    9495                        $post_author = 1; 
    9596                        $post_status = 'publish';