It does two different tasks:
- If you don’t pass in your callback name, then it checks if any callbacks are registered to the specified event.
- Else, it checks if the callback (your function, method, or closure) is registered to a specific action hook event.
- The name of the event (action hook) you want to check.
- The fully qualified name of your callback.
- If you pass in a callback, then it returns the priority number for your callback if it is registered; else you’ll get a
- Otherwise, it turns
TRUEif there are callbacks are registered; else
Show It in ActionBasic
Let’s see the
has_action function in action. In this video, you will see how it works.
Let’s see some real-world examples of how to use
has_action. You will see it being used in WordPress core and the Genesis framework. By seeing various ways of using the function, you will get ideas of how to integrate it into your projects.
Keep It Simple, Stupid (KISS) - the best kiss you'll get in code.
Let’s go into WordPress Core and look at the code which drives
has_action. You’ll also see the flowchart and sequence of operation.
These are the PHP constructs used in WordPress Core for