Apply filters to auto excerpt before tags are stripped. http://mosquito.wordpress.org/view.php?id=918 Props: kim

git-svn-id: http://svn.automattic.com/wordpress/trunk@2443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2005-03-14 01:02:04 +00:00
parent 267655af24
commit c4b6f0fa51
2 changed files with 12 additions and 17 deletions

View File

@ -45,6 +45,7 @@ if (isset($wp_version)) {
# Add Markdown filter with priority 6 (same as Textile).
add_filter('the_content', 'Markdown', 6);
add_filter('the_excerpt', 'Markdown', 6);
add_filter('the_excerpt_rss', 'Markdown', 6);
add_filter('comment_text', 'Markdown', 6);
}

View File

@ -642,28 +642,22 @@ function human_time_diff( $from, $to = '' ) {
return $since;
}
function wp_trim_excerpt( $text ) { // Fakes an excerpt if needed
function wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $post;
if ( '' == $text ) {
$text = $post->post_content;
$text = strip_tags( $text );
$blah = explode(' ', $text);
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 55;
if (count($blah) > $excerpt_length) {
$k = $excerpt_length;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
$excerpt = '';
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '[...]' : '';
$text = $excerpt;
} // end if no excerpt
}
return $text;
}
?>
?>