[wp-hackers] apply_filters() in an if statement?

Mario Peshev mario at peshev.net
Wed Feb 29 20:42:52 UTC 2012


I think that it depends on the case (i.e. on the add filters afterwards),
but anyway - apply_filters returns the result of the empty strings after
all add_filter(...) calls are applied. More here -
http://codex.wordpress.org/Function_Reference/apply_filters#Return

So there is a chance that this call is actually appropriate and correct.

Mario Peshev
Training and Consulting Services @ DevriX
http://www.linkedin.com/in/mpeshev
http://devrix.com
http://peshev.net/blog



On Wed, Feb 29, 2012 at 10:38 PM, Micky Hulse <mickyhulse.lists at gmail.com>wrote:

> Hello,
>
> Sorry in advance if this type of question belongs on the forums...
>
> I am hacking a theme, and they have something like this (abbreviated):
>
> [code]
>
> if (option('foo') || apply_filters('baz_baz', '') ||
> apply_filters('bar_bar', '')) {
>
>   $bar_bar = apply_filters('bar_bar', blah, blah);
>   $return = apply_filters('baz_baz', blah, blah);
>
> }
>
> [/code]
>
> What does apply_filters('string', '') accomplish? I guess I am
> confused because the second argument is an empty string.
>
> This helps to explain (at least in my brain) what apply_filters() does:
>
> "In the most basic terms, apply_filters is used to initialise a filter
> hook... add_filter assigns a new function to hooks that have already
> been created."
> --<
> http://stackoverflow.com/questions/2270989/what-does-apply-filters-actually-do-in-wordpress
> >
>
> But why would you put it in an if statement with an empty string for
> the second argument?
>
> Am I talking crazy here?
>
> Let me know if this type of question is too noob for this list. I
> don't want to bug folks with simple ones. :D
>
> Thanks a billion!
>
> Cheers,
> Micky
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list