[wp-hackers] anonymous functions for do_action and apply_filters

Peter Westwood peter.westwood at ftwr.co.uk
Mon Dec 20 22:15:14 UTC 2010


On 20 Dec 2010, at 20:43, Leo germani wrote:

> 
> have any of you guys discussed about adding the possibility to use php
> anonymous functions [1] with the hooks?
> 
> I mean something like:
> 
> add_filter('the_title', function($title) { return '<b>'. $title. '</b>'; });
> 
> What you think about it?
> 

As has been said elsewhere in the thread it is possible since WP3.0

It's not recommended though - any dynamic function creation isn't as it doesn't play well with object caches, being removed by other plugins, and is hard to security audti

Cheers
-- 
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