Adding Filters & Actions

 

Inside your XXX_Plugin.php class file find the function addActionsAndFilters(). Make your calls to add_action and add_filter there.

The call signatures look like this:

add_action( $tag, $function_to_add, $priority, $accepted_args );

add_filter( $tag, $function_to_add, $priority, $accepted_args );

Create a function in your class to do the action or filter. Pass it to the add_action/add_filter using array(object, function-name) syntax. For example:

 

1
2
3
4
5
6
7
public function addActionsAndFilters() {
    add_action('action_hook', array(&$this, 'doMyAction'));
}
 
public function doMyAction() {
    // do it
}

 

  One Response to “Adding Filters & Actions”

  1. Can you explain what this might be used for. How to invoke the action? Use case?

Leave a Reply to James Whalen Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>