Filters

  • Anonymous

    #2577

    I’m learning some new stuff 🙂

    How does a filter work? More specifically, how do you know it’s name? For instance, in this line:

    add_filter('graphene_header_image_height', 'graphene_custom_header_height');

    I know the second part comes from the name of the function in which you are altering the variables.

    Where does the first part come from? Is this the name of the original function? How do you go about finding all the possible filters in the theme?

    Admin

    Syahir Hakim

    #20974

    The first part is simply the name or id given to that filter by the developers (that’d be me and Jeffrey), so that you can then add functions to that filter by calling, for example:

    apply_filters( 'graphene_header_image_height', 'your_function_name' );

    Filter hook work pretty much the same to action hook, except that filter hooks are usually used in order to modify a variable value, rather than executing some arbitrary ‘action’, which is what action hook is for.

    If you’re handy with regex, you can create a function that searches all of the theme’s files for filter hooks. This is how the theme lists all the action hooks in the Action Hooks Widget Areas option.

Viewing 2 posts - 1 through 2 (of 2 total)

  • You must be logged in to reply to this topic.