[wp-hackers] new filter hook in get_option()

Peter Westwood peter.westwood at ftwr.co.uk
Fri Oct 15 15:02:27 UTC 2010


On 15 Oct 2010, at 15:58, Peter Westwood wrote:

> Hi,
> 
> On 15 Oct 2010, at 15:27, Leo germani wrote:
> 
>> Ive submited a patch to create a new filter hook in get_option() function.
>> 
>> I think its very useful and completely harmless, so I would like to ask if
>> you guys can have a look and share opinions here.
>> 
>> the description:
>> Current filter 'pre_option_$option' does not pass the option name as a
>> parameter, so you need to have one specific function for each option you
>> want to filter. This does not allow you to filter dynamically created
>> options, nor lets you filter all options if you want to do so.
>> My patch creates a new filter called 'get_option' which passes the
>> parameters 'option_name' and the 'default_value', so you can have one filter
>> to filter many options.
>> 
> 
> If you need context please use {{{current_filter()}}}.



Opps I hit send to quickly :-(

Basically, if you need to hook in one function to the pre_option_ filter for more than one option you can call current_filter and work out your context from that.

We don't need an extra filter run for every option call.

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