[wp-hackers] Avoiding Side-effects in Filters & Actions (was: Dispay none for different categories)

Peter Westwood peter.westwood at ftwr.co.uk
Wed Mar 25 20:39:44 GMT 2009

On 25 Mar 2009, at 19:53, Mike Schinkel wrote:

> That brings up a question I have for the list. WordPress' filter and  
> action hooks are incredibly flexible but can also result in far too  
> easy creation of unexpected and side effects. I've numerous times  
> made a change using a filter only to find out that it "broke"  
> something in a completely different part of the site and of course  
> those breakages are usually found by the client and then they get  
> frustrated with me for breaking "that which already works" and ask  
> me "why were you working on that part when you were supposed to be  
> working on this other part?"  And in the case of releasing a general  
> purpose plugin, such side-effects can cause a real nightmare for end- 
> users of the plugin.
> Is there a more robust way to pinpoint and isolate these kind of  
> changes?  I've reverted to testing the URLs via  
> $_SERVER['REQUEST_URI'] but that just doesn't feel very robust, and  
> in the case of a widget isn't even a solution.  How do you guys  
> address these issues, and is there even a good way to do so?

Depends on what you are filtering and what for.

If you are filtering for specific use-cases then the best thing to do  
if to only add_filter in those specific cases.

Some of the filters, especially the ones to do with SQL queries can be  
used in different ways as well.  Some with side effects and some  

It maybe that if the way you have approached the problem solution is  
to use a generic filter for a specific case rather than a specific  

It may be that the specific filter isn't available - but if you need  
more actions / filters please ask and you shall have them.

Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5

More information about the wp-hackers mailing list