Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi I'm learning theming options based on the existing theme TwentyEleven.

I've come across the following code in inc/theme-options.php

return apply_filters( 'twentyeleven_default_theme_options', $default_theme_options );

I can't seem to find the add_filter for 'twentyeleven_default_theme_options', or does it not even exist?

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

I don't believe there is an add_filter() call anywhere. If you want to override the option defaults, you can call your own add_filter() to do so, either in a Plugin or in a Child Theme.

EDIT

An apply_filters() call is nothing more than a filter hook definition: basically, it is defining the data to which a filter hook is applied.

It is similar to do_action(), which is an action hook definition: it defines the template location/runtime execution point at which the action hook is fired.

So, the presence of apply_filters() does not imply that there will necessarily be a corresponding add_filter() call; rather, it merely means that a filter is available to modify the specified data.

On the other hand, the presence of add_filter() does imply that somewhere, a corresponding apply_filters() call exists - just as the presence of an add_action() call implies that somewhere, a corresponding do_action() call exists.

share|improve this answer
    
Sorry, I'm a beginner at this. From what I read from the codex, it seems like you need to add the filter before you can apply it. But in this case the add_filter portion is missing, how does the apply_filter work? –  mitsukare Oct 19 '11 at 11:40
    
See updated answer. You've got it a bit backward. :) –  Chip Bennett Oct 19 '11 at 11:44
    
Thanks alot. I'm currently reading your post on how to incorporate the settings api, and it really helps alot! –  mitsukare Oct 19 '11 at 16:24
add comment

apply_filters is required if you want to define your own filters, or wrap the existing ones with your custom filters. That's what is happening in the code you saw. You won't need to add any custom filters at a beginner stage, so won't need to use apply_filters, at least until you get comfortable with the existing ones! WordPress provides you with a huge list of filters, check here and here for a category wise list of filters and how to use them. Start digging into these.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.