Make WordPress Core


Ignore:
Timestamp:
02/15/2005 12:21:21 AM (20 years ago)
Author:
saxmatt
Message:

Make excerpt stuff a filter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/functions-formatting.php

    r2246 r2341  
    643643}
    644644
     645function wp_trim_excerpt( $text ) { // Fakes an excerpt if needed
     646    global $post;
     647    if ( '' == $text ) {
     648        $text = $post->post_content;
     649        $text = strip_tags( $text );
     650        $blah = explode(' ', $text);
     651        $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
     666    return $text;
     667}
     668
    645669?>
Note: See TracChangeset for help on using the changeset viewer.