Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When you get down to it, there's one key element that allows for WordPress plugins, and that's the hook. Hooks are also known as actions and filters. They're basically points in the WordPress life cycle that go out and look for registered programming pieces to execute. This can occur when a user requests a page, when an admin page is created, when an admin menu is created, when the author submits a post, or at myriad of other places throughout WordPress. All of these pieces have hooks related to them. All we need to do to make a plugin work then is register a function to a specific hook, and bam: that's really all there is to it.
That piece of code will execute when that hook occurs. WordPress hook started back in version 1.2. Before that, WordPress hacking was literally that. It was taking the original code and hacking away at it. When they added hooks, essentially what they did is they added points in the code that would look to see if anything was registered to execute at that particular point. So, for example, when the user submits a comment, there is a hook there. If you want something to happen, then you can write a function that will send out an e-mail, and then you add it into that hook.
Or let's say you want to add something to a menu in admin. You can write a function that generates some user interface, some display, and then simply add a hook. That hook will then add your piece of user interface into the display of the Admin menu. So the process of plugin development is really writing a function that does something, then finding the correct hook when you want that thing to occur, and simply registering your function with that hook. As a WordPress developer, a key part of getting started is using the WordPress Codex.
The Codex is really the user manual for WordPress, for everyone, whether they're an administrator or developer. But from a developer standpoint, we have a list of all kinds of stuff: specifically here at codex.WordPress.org/plugin_API. It's a great jumping point to get started. It will explain hooks, actions and filters, what they are, and it will also tell you some examples of actions and also of filters, and we'll talk about the distinctions in these later when we get into development.
In addition, Adam Brown at Brigham Young also has a database of all the WordPress hooks, called the WordPress Hooks Database at adambrown.info. So the key to plugins is the hook. The process of developing a plugin is really the process of writing a function, registering it with a hook, and then whenever that occurs in that process when the user uses your plugin, your functionality will occur.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98365 Viewers
61 Video lessons · 85659 Viewers
71 Video lessons · 69596 Viewers
56 Video lessons · 101918 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Your file was successfully uploaded.