[wp-hackers] Linking stylesheet to RSS feeds

Austin Matzko if.website at gmail.com
Wed Jun 17 07:13:50 GMT 2009


On Wed, Jun 17, 2009 at 2:06 AM, Peter
Westwood<peter.westwood at ftwr.co.uk> wrote:
>> Austin Matzko wrote:
>>> if ( is_feed() ) {
>>>  add_filter('the_content', 'my_rss_markup_replace');
>>> }
>>>
>>> [snip]
>>>
>>> function my_rss_markup_replace($content = '')
>>> {
>>>  return preg_replace('#(<img[^>]*>)#', '<div
>>> style="margin:10px;">$1</div>', $content);
>>> }
>>> _______________________________________________
>>
>
> Looking quickly at that code I have a feeling it is safer to always add the
> filter and place the is_feed() check inside the function attached to the
> filter.
>
> When the plugin file is included is_feed() will always return false as the
> query hasn't run yet.

Yes, I am assuming a little knowledge of the WordPress action hook
API.  I didn't mean for anyone to copy and paste that straight into a
file (that's why the "[snip]").  The is_feed() block should be part of
a callback for the template_redirect hook.


More information about the wp-hackers mailing list