What is
do_action in wordpress?
Description 1.
do_action
creates the hook for things to hang. This is at the core of WordPress and even
frameworks like Genesis and many other themes and plugins. do_action is the
first domino in the chain of events with hooks. However, alone, it means
nothing and does nothing. Simply, it tells WordPress to search to see if any
functions are attached to it to fire.
Credit
: https://wpsmith.net/2011/the-difference-between-do_action-add_action-and-add_filter/
Description 2.
his function invokes
all functions attached to action hook $tag
. It is possible to create new action hooks by simply calling
this function, specifying the name of the new hook using the $tag
parameter
Credit : https://developer.wordpress.org/reference/functions/do_action/
Description 3.
Use do_action( 'unique_name' ) to
create your own actions.
You can use that to offer an API for your plugin, so
other plugins can register callbacks for your custom action.
add_action() and do_action() are not necessary tied together.
Great Reference link for do_action
https://wordpress.stackexchange.com/questions/120339/difference-between-do-action-and-add-action
https://wordpress.stackexchange.com/questions/64677/do-i-need-to-call-do-action-in-my-plugin/64678#64678
No comments:
Post a Comment