How to use actions and filters to customize Jetpack?

This site lists all hooks included in Jetpack. It is updated for every Jetpack release.

What are hooks, you ask? Hooks are methods that allow you to “hook into” the Jetpack plugin, or WordPress itself. There are two kinds of hooks: actions and filters.

Actions are triggered by specific events that take place in WordPress or in Jetpack, such as publishing a post, changing themes, or displaying an admin screen. You can define a custom PHP function in your plugin and hook it (i.e., configure it to respond) to these events.

An example of an action would be be a plugin that emails you whenever a new user registers on your site. In this case, WordPress realizes a new user has registered and fires any actions that are registered for that event.

Actions are called with the do_action() function.

Filters are functions that WordPress or Jetpack passes data through just before doing something with that data (e.g. displaying it in the browser). Filters sit between the database and the browser and modify data as it goes back and forth between the two.

An example of a filter would be a plugin that looks for common misspellings in posts and corrects them before they’re displayed. In this case, the filter might detect that you have the word “alot” in your database, but it displays “a lot” in the browser instead.

Filters are called with the apply_filters() function.

Actions and filters can be used to change Jetpack’s default behavior without editing the actual Jetpack files. This is a best practice because, if you did edit the core files, those changes would be overwritten the next time that plugin is updated.

To better organize your changes and protect them from updates, you should create code snippets using actions and filters to hook into the core Jetpack code without touching that code.

How to add code snippets to your site

There are 3 main ways to add code snippets to your site: