### 3. Extending Markup

Let's extend on example number 2 now and make it even better. We already added a filter that allows users to modify the query, now let's add a few hooks to let us alter the HTML that is created.

First we'll modify our original HTML a bit:

We would now like to make it possible for developers to add in extra markup at various points, such as the following:

• Before any HTML is outputted
• After the ending HTML
• Before the title of each book
• After the title of each book

You can imagine a scenario where a user would want to add a thumbnail before or after the book title. To make this possible, we use do_action() to create hookable locations, like this:

Note that the two inner hooks (surrounding the title) have a second parameter of get_the_ID(). This variable, which will be the ID of the book, will be available as a parameter to any hooked function. To add in a book thumbnail, for example, we can do this:

## Real World Examples

I would like to now show you some real world examples of plugins that are extensible, including samples of some of their extensible functions.

### 1. Soliloquy

Soliloquy is a powerful WordPress responsive image slider plugin that makes creating and maintaining responsive, efficient, secure and SEO friendly image sliders a breeze.

Nearly everything in this plugin is extensible. Here's just one example:

This is how Thomas Griffin (the plugin's developer) sets up the arguments for both the custom post type labels and attributes. The presence of his two filters, tgmsp_post_type_labels and tgmsp_post_type_args, make it very simple for other developers to rename the slider post type or change what the post type supports.

### 2. bbPress

By far one of my personal favorite plugins of all time, bbPress is a fully featured forum plugin for WordPress. The entire plugin is a perfect example of how to make your plugins extensible, as it literally has actions and filters everywhere. It has one particular filter that is applied when retrieving the content of a forum:

Before the content of the forum is returned, it is passed through a filter called bbp_get_forum_content that makes it possible for a developer to modify the content before it is ever displayed.

Easy Digital Downloads, or EDD, is one of my plugins that was built to make it exceptionally easy to sell digital products through WordPress. As with most ecommerce plugins, EDD has a checkout process that the buyer goes through so they can enter their personal and payment details. After all of that info is collected, it all goes to a payment gateway (a system for processing the payment), but before it goes to the gateway, a filter is applied that allows the data to be manipulated before it is used by the payment system:

The presence of this filter makes it possible to adjust purchase amounts (perhaps for special discounts), add taxation, perhaps add or remove products from the purchase, and much, much more.

## Conclusion

Extensible plugins benefit everyone: the original developer, other developers, and the users themselves.

There are so many reasons why you should write your plugins with extendable code in mind, so why don't you?

The tools presented here are everything that you need to get started. Have questions? Ask away!