| 1 | Index: wp-includes/formatting.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/formatting.php (revision 17609) |
|---|
| 4 | +++ wp-includes/formatting.php (working copy) |
|---|
| 5 | @@ -1859,23 +1859,38 @@ |
|---|
| 6 | function wp_trim_excerpt($text) { |
|---|
| 7 | $raw_excerpt = $text; |
|---|
| 8 | if ( '' == $text ) { |
|---|
| 9 | - $text = get_the_content(''); |
|---|
| 10 | + global $page, $pages, $preview; |
|---|
| 11 | |
|---|
| 12 | + $is_teaser = false; |
|---|
| 13 | + |
|---|
| 14 | + $text = $pages[$page-1]; |
|---|
| 15 | + |
|---|
| 16 | + if ( preg_match('/<!--more(.*?)?-->/', $text, $matches) ) { |
|---|
| 17 | + list($text) = explode($matches[0], $text, 2); |
|---|
| 18 | + $is_teaser = true; |
|---|
| 19 | + } |
|---|
| 20 | + |
|---|
| 21 | + if ( $preview ) // preview fix for javascript bug with foreign languages |
|---|
| 22 | + $text = preg_replace_callback('/\%u([0-9A-F]{4})/', '_convert_urlencoded_to_entities', $text); |
|---|
| 23 | + |
|---|
| 24 | $text = strip_shortcodes( $text ); |
|---|
| 25 | |
|---|
| 26 | $text = apply_filters('the_content', $text); |
|---|
| 27 | $text = str_replace(']]>', ']]>', $text); |
|---|
| 28 | $text = strip_tags($text); |
|---|
| 29 | $excerpt_length = apply_filters('excerpt_length', 55); |
|---|
| 30 | - $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); |
|---|
| 31 | + $excerpt_more = apply_filters('excerpt_more', ' [...]'); |
|---|
| 32 | $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); |
|---|
| 33 | + |
|---|
| 34 | if ( count($words) > $excerpt_length ) { |
|---|
| 35 | array_pop($words); |
|---|
| 36 | - $text = implode(' ', $words); |
|---|
| 37 | + $is_teaser = true; |
|---|
| 38 | + } |
|---|
| 39 | + |
|---|
| 40 | + $text = implode(' ', $words); |
|---|
| 41 | + |
|---|
| 42 | + if ( $is_teaser ) |
|---|
| 43 | $text = $text . $excerpt_more; |
|---|
| 44 | - } else { |
|---|
| 45 | - $text = implode(' ', $words); |
|---|
| 46 | - } |
|---|
| 47 | } |
|---|
| 48 | return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); |
|---|
| 49 | } |
|---|