WordPress.org

Make WordPress Core

Ticket #10376: formatting-preg-split.php.diff

File formatting-preg-split.php.diff, 668 bytes (added by sojweb, 5 years ago)
  • trunk/wp-includes/formatting.php

     
    16961696 
    16971697                $text = apply_filters('the_content', $text); 
    16981698                $text = str_replace(']]>', ']]>', $text); 
    1699                 $text = strip_tags($text); 
    17001699                $excerpt_length = apply_filters('excerpt_length', 55); 
    1701                 $words = explode(' ', $text, $excerpt_length + 1); 
     1700                $words = preg_split('/\s+/', strip_tags($text), $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); 
    17021701                if (count($words) > $excerpt_length) { 
    17031702                        array_pop($words); 
    17041703                        array_push($words, '[...]');