Remove WordPress Action / Filter Hooks by Name

The WordPress remove_action() and remove_filter() functions are useful, but they require the original hook priority and a function name, a class object and method name, or a class name and static method name.

Providing the class object in particular may be difficult or impossible, as plugin and theme classes may be extended and instantiated any number of ways. The following SucomUtilWP::remove_filter_hook_name() static method can be used to remove WordPress action and filter hooks using their class name instead of requiring a class object.

For example, if an action hook like this one has been added within a class object that was not saved, saved in a private/protected variable, or cannot be re-instantiated, then removing it might be impossible.

If you know the class (or extended class) name (‘Plugin_Namespace\Class_Name’ for this example), you can remove it using the following static method:

The SucomUtilWP::remove_filter_hook_name() static method:

Find this content useful? Share it with your friends!