Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#15054 closed enhancement (worksforme)

Add filter hook to get_option

Reported by: leogermani's profile leogermani Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: General Keywords: has-patch
Focuses: Cc:

Description

Add a filter hook to get_option function to allow plugins to filter options.

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.

Attachments (1)

get_option_filter.patch (1.0 KB) - added by leogermani 14 years ago.
add filter to get_option function

Download all attachments as: .zip

Change History (7)

@leogermani
14 years ago

add filter to get_option function

#1 @scribu
14 years ago

  • Keywords has-patch added; get_option filter hook removed

#2 @bireme
14 years ago

+1 this can be very useful

#3 @Mvied
14 years ago

+1 Definitely need this.

#4 @chrisbliss18
14 years ago

  • Cc gaarai@… added

Since this does have performance implications, can you clarify the value of adding this filter with some examples of when code would need to be able to filter any and all options even when it doesn't know what the options are.

#5 @westi
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

If you need context please use current_filter().

#6 @leogermani
14 years ago

I wanted it to use in a multi language plugin Im writing.

For instance, I want to filter all options, and, if Im visiting other language than the default, I will return 'myplugin_$language_$option' value instead of $option value.

Using current_filter() is a valid workaround. The only thing is that I have to do a foreach in all existing opions to add a filter for each one.

Anyways, current_filter is fine

cheers

Note: See TracTickets for help on using tickets.