How do do_action and add_action work?

前端 未结 4 1373
执念已碎
执念已碎 2020-12-14 18:42

I am trying to find what exactly do_action and add_action works. I already examine with add_action but for do_action i am trying as new now. This what i tried.



        
4条回答
  •  自闭症患者
    2020-12-14 18:57

    Actually, the add_action is an action hook which is used to invoke an action (a registered handler) on a certain point depending on the action and the do_action is used to manually invoke that registered action. For example:

    add_action('some_hook', 'handler_for_some_hook');
    

    This handler will be invoked when you take or the script does the some_action but if you want you may invoke that action manually using the do_action. So, basically the do_action invokes the registered action hook when you call it. Check more on Codex.

提交回复
热议问题