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.
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.
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. […]
WordPress Plugin API – Introduction & Registering Event Hooks
The Event System in WordPress Plugin API is the cornerstone for developers, as it allows you to extend, enhance, and change the behavior of WordPress. In this lab, you will be introduced to the event-driven mechanism. Then you’ll get to work registering callbacks for events (actions and filters) to help you know this important API. Let’s dig into add_filter and add_action.
WordPress Tip: Do You Have to Specify all the Arguments for add_action and add_filter?
The question I often get is: If I only need a couple of the arguments that a filter or action makes available, do I have to specify all of them in the callback function for add_filter() and add_action(). For example, if a filter, such as shortcode_atts_{$shortcode} has 4 arguments, but I only need 3, do I have to wire it up for all 4? In this video, Tonya explains why you have control over what you want to receive by looking into WordPress core at apply_filters().