wp_filter

WordPress provides a facility of hooks. They can be used by plugin and theme developers can modify custom behavior at different points in WordPress. Mark Jaquith has compiled a directory of hooks provided by WordPress.

Actions and filters are two different types of hooks, they are semnatically different but syntactically the same. These filters and actions are stored in the wp_filter global variable. It is set using add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) function defined in [wordpress root folder]/wp-includes/functions.php.

WordPress adds certain default actions and filters, most of which are done in [wordpress root folder]/wp-includes/default-filters.php. Function do_action($tag, $arg = ”) is used internally by WordPress to invoke the different registered filters and actions.

Plugin and theme developers can define custom functions and add them as filters or actions using the following functions provided by WordPress:

  • add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1): to register filters
  • add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1): to register actions
  • remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1): to remove filters
  • remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1): to remove actions

Back to full list of global variables.

Technorati tags: , , , , , , , ,

One Response to “wp_filter”


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: