Give plugins and themes simple control over the text displayed at the end of an autogenerated excerpt. Fixes #10395 props ramiy.

git-svn-id: https://develop.svn.wordpress.org/trunk@11907 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2009-09-09 16:34:44 +00:00
parent d7dede3b5f
commit 925df4bd49
1 changed files with 6 additions and 2 deletions

View File

@ -1696,9 +1696,12 @@ function human_time_diff( $from, $to = '' ) {
* that, then the string '[...]' will be appended to the excerpt. If the string
* is less than 55 words, then the content will be returned as is.
*
* The 55 word limit can be modified by plugins/themes using the excerpt_length filter
* The '[..]' string can be modified by plugins/themes using the excerpt_more filter
*
* @since 1.5.0
*
* @param string $text The exerpt. If set to empty an excerpt is generated.
* @param string $text The excerpt. If set to empty an excerpt is generated.
* @return string The excerpt.
*/
function wp_trim_excerpt($text) {
@ -1712,10 +1715,11 @@ function wp_trim_excerpt($text) {
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', '[...]');
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
array_push($words, $excerpt_more);
$text = implode(' ', $words);
}
}