WordPress.org

Support

Support » Plugins and Hacks » Hacks » additionals arguments in apply_filters()

additionals arguments in apply_filters()

  • Hi all,
    I try to understand what for are the additional arguments in apply_filters in validation of the theme option in Twenty Eleven theme.
    I mean what for the arrays $input and $defaults in this function are needed.

    function twentyeleven_theme_options_validate( $input ) {
    	/* some code */
    	return apply_filters( 'twentyeleven_theme_options_validate', $output, $input, $defaults );
    }

    In Twenty Eleven it’s the file: themes/twentyeleven/inc/theme-options.php line 334-353.

    Could anybody explain it to me?

    Thanks in advance,
    Bernard

Viewing 2 replies - 1 through 2 (of 2 total)
  • bcworkz
    Participant

    @bcworkz

    Short answer: They are not necessarily needed, but might be useful to someone extending the theme.

    Discussion: apply_filters() executes any callback functions hooked to a particular tag. The parameters passed are for the use of the callback function to do whatever it needs to do. The function can ignore them if it doesn’t need them.

    I don’t think this filter hook does anything by default. You can grep the theme folder for any add_filter() calls using this tag to verify this, I haven’t. It appears to exist so the theme can be extended and the extension developer can hook this filter to validate their own options. The $input and $default parameters are passed so any extension has all pertinent information at hand. We can only guess about how this information might be used by a future developer, that is the nature of filter hooks.

    I have no special insight into what the theme authors had in mind with this hook, this is all conjecture based solely on the code that I see, and how other filter hooks have been used else where.

    Thanks bcworkz, you can be right.
    Regards,
    Bernard

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘additionals arguments in apply_filters()’ is closed to new replies.