WordPress函数文档do_action()

执行一个动作钩子,调用所有回调方法 描述 Execute functions hooked on a spec…

执行一个动作钩子,调用所有回调方法

描述

Execute functions hooked on a specific action hook.

This 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. You can pass extra arguments to the hooks, much like you can with apply_filters(). This function works similar to apply_filters() with the exception that nothing is returned and only the functions or methods are called.

You can hook a function to an action hook using add_action().

用法

 <?php do_action$tag$arg ); ?> 

Multiple Arguments: <?php do_action$tag$arg_a$arg_b$etc ); ?> 

参数

$tag

(string) (必填) The name of the hook you wish to execute.

默认值: None

$arg

(mixed) (可选) The list of arguments to send to this hook.

默认值: Empty string

返回值

This function does not return a value.

注意

  • 使用到: global $wp_filter – Stores all of the 过滤器s and 动作s.
  • 使用到: global $wp_actions – Increments the amount of times the 动作 was triggered.

历史

添加于 版本: 1.2.0

源文件

do_action() 函数的代码位于 wp-includes/plugin.php.

相关

Actions:
has_action(),
add_action(),
do_action(),
do_action_ref_array(),
did_action(),
remove_action(),
remove_all_actions()

  • 原文:http://codex.wordpress.org/Function_Reference/do_action
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT