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 Markdown filter with priority 6 (same as Textile).
add_filter('the_content', 'Markdown', 6); add_filter('the_content', 'Markdown', 6);
add_filter('the_excerpt', 'Markdown', 6); add_filter('the_excerpt', 'Markdown', 6);
add_filter('the_excerpt_rss', 'Markdown', 6);
add_filter('comment_text', 'Markdown', 6); add_filter('comment_text', 'Markdown', 6);
} }

View File

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