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

目录

描述

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().

do_action() 描述

用法

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

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

do_action() 用法

参数

$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

do_action() 参数

返回值

This function does not return a value.

do_action() 返回值

注意

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

do_action() 注意

历史

添加于 版本: 1.2.0

do_action() 历史

源文件

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

do_action() 源文件

相关