Skip to content

Commit 310589c

Browse files
committed
Apply filters to auto excerpt before tags are stripped. http://mosquito.wordpress.org/view.php?id=918 Props: kim
git-svn-id: https://develop.svn.wordpress.org/trunk@2443 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 1e268f4 commit 310589c

2 files changed

Lines changed: 12 additions & 17 deletions

File tree

wp-content/plugins/markdown.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
# Add Markdown filter with priority 6 (same as Textile).
4646
add_filter('the_content', 'Markdown', 6);
4747
add_filter('the_excerpt', 'Markdown', 6);
48+
add_filter('the_excerpt_rss', 'Markdown', 6);
4849
add_filter('comment_text', 'Markdown', 6);
4950
}
5051

wp-includes/functions-formatting.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -642,28 +642,22 @@ function human_time_diff( $from, $to = '' ) {
642642
return $since;
643643
}
644644

645-
function wp_trim_excerpt( $text ) { // Fakes an excerpt if needed
645+
function wp_trim_excerpt($text) { // Fakes an excerpt if needed
646646
global $post;
647647
if ( '' == $text ) {
648648
$text = $post->post_content;
649-
$text = strip_tags( $text );
650-
$blah = explode(' ', $text);
649+
$text = apply_filters('the_content', $text);
650+
$text = str_replace(']]>', ']]>', $text);
651+
$text = strip_tags($text);
651652
$excerpt_length = 55;
652-
if (count($blah) > $excerpt_length) {
653-
$k = $excerpt_length;
654-
$use_dotdotdot = 1;
655-
} else {
656-
$k = count($blah);
657-
$use_dotdotdot = 0;
658-
}
659-
$excerpt = '';
660-
for ($i=0; $i<$k; $i++) {
661-
$excerpt .= $blah[$i].' ';
653+
$words = explode(' ', $text, $excerpt_length + 1);
654+
if (count($words) > $excerpt_length) {
655+
array_pop($words);
656+
array_push($words, '[...]');
657+
$text = implode(' ', $words);
662658
}
663-
$excerpt .= ($use_dotdotdot) ? '[...]' : '';
664-
$text = $excerpt;
665-
} // end if no excerpt
659+
}
666660
return $text;
667661
}
668662

669-
?>
663+
?>

0 commit comments

Comments
 (0)