Let’s figure out where we can hook into the theme to add the content from the editor. Each theme will be different. You will need to evaluate your theme in order to determine where you can hook into for rendering out the content. In this episode, you will look at two themes. First, you will dive into the Genesis framework and look at where the page title is being rendered for the Posts Page, i.e. found in genesis/lib/structure/archive.php. You will see which event you need to register to in the plugin in order to add in the content. Then you […]
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
WordPress Plugin API – Loading Plugins
WordPress auto discovers the main plugin file for each plugin and then loads it. How does it do this? How does it know which file is the main one in your plugin directory? In this Pro Lab, you’ll go into WordPress Core, walk through the code, and then reverse engineer it. This lab will help you to know how your plugin files are being read, discovered, and loaded.
PHP Argument Lookup Table
Let’s go deeper to understand what happens when arguments are passed to a function. How does PHP manage them? If you pass more arguments than a function needs, what happens? How do you access them? The following PHP constructs were presented to you in this video: func_get_arg and func_get_args.
Number of Arguments to Pass to the Callback
The last parameter for registering your callback to the event is the number of arguments. It specifies the number of arguments your callback wants to receive. You will learn about the difference between required and optional parameters in PHP. You’ll see what happens when you send too few and too many arguments to your callback.
WordPress Event Priority Level
Let’s see what the priority level parameter does. How does it affect the order of code execution (i.e. when code is called and works)? With a filter, what is the order to changing the value that is passed to each of the callbacks?
WordPress Event Lookup Table
You will meet the WordPress Event Lookup Table, which holds all of the events. Yup, it holds both the filters and actions all in one event lookup table. In this video, you will look at the actual table and we’ll discuss how it is structured including the event name, priority, callbacks, and the number of arguments.
Let’s Look at add_filter in Core
Let’s look at add_filter in WordPress Core. You will find it in the wp-includes/plugin.php file. Here is a link to core trac.
Introducing Filter Event
Let’s start with registering a callback from your Starter Plugin to the post title, i.e. the_title event. You will learn more about namespaces and the full qualified name of your callback. In this video you will learn and see the following: Actions and filters are both stored in one lookup table, i.e. $wp_filter. The lookup table is a large, multi-dimensional array. The priority is the main key for each event and they are sorted. You can set the priority of when you want your event to fire. However, you can’t set the granular sub-priority level within the priority. For example, […]
The Difference Between Action & Filter
Let’s look at what the real difference is between a WordPress action and filter event. Technically there is only one difference. The filter event returns the value, whereas an action event does not. That’s it. That’s the only difference between the two.
What is the Event Management System?
What is the Event Management System within the Plugin API? It is the system that allows you and I, as developers, to extend, customize, and enhance the website and user experience (UX). It allows you to register your code to specific events and then get called for your code to do its thang. WordPress provides us the ability to hook into Core, plugins, and the theme in order to run our code when some event occurs. Think about that. WordPress Core loads and runs in a specific order. It allows the plugins and theme at different points in that sequence. […]