There are times when you can’t get a hold of the object in order to remove a method callback from that object. The author wrote it such that s/he did not expose the object for you. What do you do? How can you get that object in order to do your work and unregister its callback?
Here are strategies in order:
- Talk to the author and see s/he will add a filter or action to pass the object to you.
- If it’s open source, submit a pull request to add the filter/action code.
- Evaluate if you have to use this particular plugin.
- If all else fails, then you may have to do it the hard way by manually removing it from the
You can ask the author to do the following to make their code better:
$my_object = new My_Class(); do_action( 'plugin_name_object_created', $my_object );
DON’T ASK THEM TO MAKE IT A GLOBAL VARIABLE!!!
Don’t repeat yourself. Don’t repeat yourself. Don’t repeat yourself.
Total Lab Runtime: 01:58:04
- 1 Lab Introductionfree 10:43
- 2 Meet the PHP Callbackpro 15:01
- 3 Object's Method Callbackpro 11:30
- 4 Static Method Callbackpro 13:32
- 5 Registering an Object's Method to a WordPress Event Hookpro 12:32
- 6 Registering a Static Method to a WordPress Event Hookpro 05:09
- 7 Unregistering a Static Method Callbackpro 03:30
- 8 Unregistering an Object's Method Callbackpro 04:49
- 9 3rd Party Object Callbackspro 15:06
- 10 3rd Party Static Callbackspro 08:27
- 11 "Object Not Available" Strategiespro 08:52
- 12 Design Strategypro 03:29
- 13 Wrap it Uppro 05:24