WordPress API Hooks For Developers And Designers

Filed under: Wordpress Tips

wordpress-logoWhen the developers of  WordPress add a core feature they allow developers access to the code by the way of API hooks.

In this way a site owner or plugin developer can insert some of their own actions before or after an event happens and not have to drill through the source code and manually edit core files.

This method is the preferred way to adapt WordPress to meet your needs.

Using Action Hooks will also allow you to upgrade your WordPress version without the need to re-edit core files.

The method of accessing the WordPress API Hooks is to add an action:

add_action ( 'hook_name', 'your_function_name', [priority], [accepted_args] );

Your action will point to the Hook you want to intercept and your Function that you wrote to perform the work.

By using hooks you could modify your install of WordPress to provide features for Writers, Administrators and your readers.

If security is a concern you could setup Hooks to email administrators when Actions occur or lock out staff or visitors by password or ip.

For a list of some of the hooks please review

http://codex.wordpress.org/Plugin_API/Action_Reference

Filters are another tool that developers can use to intercept data while it is being processed.

Filters can examine and modify the content of data before it is sent to your viewers.

A unique application of a filter may be a translation service or the filtering of comments however comment filtering is best done when it is transmitted to your wordpress database and not when it is sent back to your visitors.

Another application of filters may be to examine all of the links in user comments and add a NoFollow or redirect to a Framed page to keep your users and bots within your site.