wp_trim_excerpt() is not filterable
|Reported by:||coffee2code||Owned by:|
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.