WordPress.org

Make WordPress Core

Changeset 2443


Ignore:
Timestamp:
03/14/2005 01:02:04 AM (17 years ago)
Author:
ryan
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-content/plugins/markdown.php

    r2128 r2443  
    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}
  • trunk/wp-includes/functions-formatting.php

    r2428 r2443  
    643643}
    644644
    645 function wp_trim_excerpt( $text ) { // Fakes an excerpt if needed
     645function 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].' ';
    662         }
    663         $excerpt .= ($use_dotdotdot) ? '[...]' : '';
    664         $text = $excerpt;
    665     } // end if no excerpt
     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);
     658        }
     659    }
    666660    return $text;
    667661}
Note: See TracChangeset for help on using the changeset viewer.