[wp-trac] [WordPress Trac] #9558: wp_trim_excerpt() is not filterable

WordPress Trac wp-trac at lists.automattic.com
Fri Apr 17 06:55:16 GMT 2009


#9558: wp_trim_excerpt() is not filterable
-------------------------+--------------------------------------------------
 Reporter:  coffee2code  |       Owner:  anonymous
     Type:  enhancement  |      Status:  new      
 Priority:  low          |   Milestone:  2.8      
Component:  Template     |     Version:  2.7.1    
 Severity:  minor        |    Keywords:  has-patch
-------------------------+--------------------------------------------------
 `the_excerpt()`, used by most themes to obtain the excerpt for a post,
 calls `get_the_excerpt()` which in turn calls `wp_trim_excerpt()`.
 `wp_trim_excerpt()` will fabricate an excerpt for a post if one wasn't
 explicitly defined (and in doing so makes a number of assumptions about
 how to generate the except (i.e. stripping shortcodes and tags, grabbing
 so many words, and appending a non-filterable ellipsis of sorts (perhaps
 that bit is a separate ticket itself)).

 Anyhow, the primary need in filtering `wp_trim_excerpt()` rather than
 fiddling with the excerpt via filters for `get_the_excerpt()` or
 `the_excerpt()` is that with the latter two it is not clear whether the
 excerpt is real or fabricated.

 The attached patch simply adds a filter on the return value of
 `wp_trim_excerpt()`.  It sends along the potentially-generated excerpt as
 well as the original (raw) excerpt that was passed in, allowing plugins to
 identify a fabricated excerpt and react accordingly.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/9558>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list