WordPress.org

Make WordPress Core

Changeset 13942


Ignore:
Timestamp:
04/02/2010 07:10:51 AM (9 years ago)
Author:
dd32
Message:

A better default except, Remove multiple white spaces from the except as well as splitting safely on UTF8 strings. Props Denis-de-Bernardy for the UTF8 split. Fixes #10376

File:
1 edited

Legend:

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

    r13914 r13942  
    18451845        $excerpt_length = apply_filters('excerpt_length', 55);
    18461846        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    1847         $words = explode(' ', $text, $excerpt_length + 1);
    1848         if (count($words) > $excerpt_length) {
     1847        $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
     1848        if ( count($words) > $excerpt_length ) {
    18491849            array_pop($words);
    18501850            $text = implode(' ', $words);
    18511851            $text = $text . $excerpt_more;
     1852        } else {
     1853            $text = implode(' ', $words);
    18521854        }
    18531855    }
Note: See TracChangeset for help on using the changeset viewer.