Wednesday, April 27, 2016

Demystifying the WordPress Hook System

If you've been developing websites with WordPress (including plugin and theme development) chances are you’ve heard these terms: Hooks, Actions, and Filters. WordPress uses the Event-driven Architecture Pattern.

Are you new to WordPress development or finding it difficult to understand the basic concepts? I can’t recommend highly enough Simon Codrington’s Introduction to WordPress Plugin Development tutorial. He did a great job of explaining Actions, and Filters.

In this tutorial, I will be demystifying the WordPress hook system, leaving no stone unturned. Without further ado, let’s get started.

Hooks, Actions, Filters. What Are They?

'Hooks' are basically events triggered by WordPress core, themes and plugins at various stages of their execution or interpretation by PHP. When these events are triggered, all the functions and/or class methods hooked or attached to them are executed in their correct order.

Hooks come in two forms, Actions and Filters. While the former is used to add and remove features or functionalities at various stages of execution process, the latter modifies the behavior of various features and implementations. Don’t worry if you still don’t understand. You will when we start seeing some code examples below.

Importance of the Hook System in WordPress

The importance of the hook system in WordPress is simply extensibility. It makes it possible to add and remove features, as well as tweak/modify the implementation of features in WordPress core, plugins and themes.

When you write extensible plugins and themes, you make it possible for other developers to improve and extend them without ever editing the core source code.

Continue reading %Demystifying the WordPress Hook System%


by Agbonghama Collins via SitePoint

No comments:

Post a Comment