Identifying Functionality and Output

Actions and filters hook our functions to WordPress plugin API commands. By now, you should have an understanding of how this works and how it looks in a plugin file. In generic terms, WordPress plugins have two distinct purposes:

  • Functions: Defined within the plugin code through a combination of actions and hooks; essentially, functions define what the plugin does.
  • Output: What is displayed on your site as a result of the plugin function(s). For example, if the plugin function(s) makes calls to the database to retrieve a certain type of post (for instance, from a certain category or tag) from your content, the output is how those posts then get displayed on your site for your readers to see. Plugins can also use HTML markup and CSS to provide basic styling for the output.

Members of the WordPress community eager to learn more often ask how to go about dissecting a WordPress plugin, possibly to modify its internal functionality or even its output. In Book VII, Chapter 5, we discuss providing an API specific to your plugin. You can determine a plugin function, as well as how it outputs the result of the functions on your Web site by taking a look at the source code of the plugin.

When digging into an existing plugin that you'd like to alter, you want figure out what action and filter hooks it's using. Some plugins make this easy by putting most or all of the calls to hooks at the bottom of a file (often the primary plugin file). We use a plugin ...

Get WordPress® All-in-One For Dummies® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.