Unregistering an object’s method callback is the same as registering it. Remember that you need the following: The name of the method The object

Developing & Empowering WordPress Developers
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.
0 Videos Runtime
Unregistering an object’s method callback is the same as registering it. Remember that you need the following: The name of the method The object
0 Videos Runtime
Unregistering a static method is the same as registering, except that you use remove_action or remove_filter. Keep the syntax the same.
0 Videos Runtime
Let’s talk about how to make a static method a callback in PHP. You will need this in order to understand the syntax and how it works when registering a static to a WordPress hook event.
0 Videos Runtime
Let’s walk through registering a static method to a WordPress Event, such as init. You’ll do it both internally within the class blueprint and outside of it.
0 Videos Runtime
Now that you know how to make an object’s method a callback, let’s apply it to registering a method to a WordPress event. You’ll look in WordPress Core where it is using call_user_func_array(). Therefore, the same syntax rules and approach applies for you register it to a specific event. You’ll see how the object’s method is registered and added to the WordPress Event Registry, which is stored in $wp_filter. You’ll see how the key for it includes the object’s ID plus the method name. You’ll see the array is used as $the_[‘function’].
0 Videos Runtime
Functions and methods can be dynamically called in PHP as a callback. In this episode, let’s talk about callables and callbacks, to get you prepared for how WordPress events actually work.
0 Videos Runtime
In the last episode, you saw how to dynamically call a procedural function using call_user_func_array( ‘fully/qualified/function_name’, array( ‘args to pass’ ) );. How do you call a method on an object? Let me show you in this episode. You’ll register the methods from within and outside of an object.
0 Videos Runtime
Before you begin, make sure that you have the code from the Introduction to PHP Object-Oriented Programming (OOP) for WordPress lab. If you do not have that code, no problem, as you can get it from this GitHub repository. Let’s talk about the WordPress event-driven system. Then you’ll look at the code in WordPress Core to use how it’s using the PHP construct call_user_func_array in order to call each of the pre-registered callbacks when the event is fired. It’s important to have a basic understanding of hooks, which are events and why they exist. In this episode, you’ll get a […]
13 Videos 01:58:04 Runtime
Registering and unregistering WordPress hook callbacks is different with PHP objects. In this hands-on lab, you’ll learn the syntax, why it’s different, how to register and unregister, as well as strategies to work with other plugins.
0 Videos Runtime
Let’s review what you learned in this lab. Then I’ll give you some resources to continue learning about OOP. Congratulations for completing this lab! Other PHP Resources A collection of other awesome educational resources. Want to really level up in PHP? Make sure you also join PHP Nomad. Leading PHP developers share their insights with you each month. Their libraries are filled with PHP awesomeness. If you are a member, they have a deal waiting for you….3 months for FREE! Object-Oriented Bootcamp in PHP – Laracasts Jeffrey Way at Laracasts has an awesome Object-Oriented Bootcamp. If you get a chance, […]
Know the Code flies on WP Engine. Check out the managed hosting solutions from WP Engine.
WordPress® and its related trademarks are registered trademarks of the WordPress Foundation. The Genesis framework and its related trademarks are registered trademarks of StudioPress.
This website is not affiliated with or sponsored by Automattic, Inc., the WordPress Foundation, or the WordPress® Open Source Project.