Make WordPress Core

Ticket #12084: excerpt_tags2.diff

File excerpt_tags2.diff, 1.0 KB (added by sillybean, 15 years ago)

balances tags after truncating excerpt

  • Users/steph/Documents/code/WordPressSVN/trunk/wp-includes/formatting.php

     
    18071807        $raw_excerpt = $text;
    18081808        if ( '' == $text ) {
    18091809                $text = get_the_content('');
    1810 
    1811                 $text = strip_shortcodes( $text );
    1812 
    18131810                $text = apply_filters('the_content', $text);
    18141811                $text = str_replace(']]>', ']]>', $text);
    1815                 $text = strip_tags($text);
     1812                $excerpt_tags = apply_filters('excerpt_tags', '');
     1813                $text = strip_tags($text, $excerpt_tags);
    18161814                $excerpt_length = apply_filters('excerpt_length', 55);
    18171815                $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    18181816                $words = explode(' ', $text, $excerpt_length + 1);
    18191817                if (count($words) > $excerpt_length) {
    18201818                        array_pop($words);
    18211819                        $text = implode(' ', $words);
     1820                        $text = force_balance_tags($text);
    18221821                        $text = $text . $excerpt_more;
    18231822                }
    18241823        }