do_action( string $tag, $arg = '' )
Execute functions hooked on a specific action hook.
执行特定功能的动作钩子
Description
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().
描述
这个函数的所有函数invokes行动钩标签附加到美元。它是由可能创建新动作,简单的调用该函数的钩,钩的新指定的名称标签参数使用美元。
额外的参数,你可以传递到了钩,你可以与_状滤波器(应用)。
Parameters #参数Parameters
-
$tag
-
(string) (Required) The name of the action to be executed.(必填)钩子的名称
$arg,...
-
(mixed) (Optional) Additional arguments which are passed on to the functions hooked to the action. Default empty.
-
这是附加的参数(可选)通过在线的功能钩的动作。默认是空的。
-
-
Source #Source
File: wp-includes/plugin.php
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456function
do_action(
$tag
,
$arg
=
''
) {
global
$wp_filter
,
$wp_actions
,
$wp_current_filter
;
if
( ! isset(
$wp_actions
[
$tag
]) )
$wp_actions
[
$tag
] = 1;
else
++
$wp_actions
[
$tag
];
// Do 'all' actions first
if
( isset(
$wp_filter
[
'all'
]) ) {
$wp_current_filter
[] =
$tag
;
$all_args
= func_get_args();
_wp_call_all_hook(
$all_args
);
}
if
( !isset(
$wp_filter
[
$tag
]) ) {
if
( isset(
$wp_filter
[
'all'
]) )
array_pop
(
$wp_current_filter
);
return
;
}
if
( !isset(
$wp_filter
[
'all'
]) )
$wp_current_filter
[] =
$tag
;
$args
=
array
();
if
(
is_array
(
$arg
) && 1 ==
count
(
$arg
) && isset(
$arg
[0]) &&
is_object
(
$arg
[0]) )
// array(&$this)
$args
[] =&
$arg
[0];
else
$args
[] =
$arg
;
for
(
$a
= 2,
$num
= func_num_args();
$a
<
$num
;
$a
++ )
$args
[] = func_get_arg(
$a
);
$wp_filter
[
$tag
]->do_action(
$args
);
array_pop
(
$wp_current_filter
);
}
Expand full source code View on Trac