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
This commit is contained in:
parent
1e268f40ac
commit
310589c667
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user