1. 首页
  2. WordPress 函数手册

do_action_ref_array()

do_action_ref_array( string $tag, array $args )

调用已添加到操作挂钩的回调函数,并在数组中指定参数。
Calls the callback functions that have been added to an action hook, specifying arguments in an array.

目录锚点:#说明#参数#返回#源码#笔记


说明(Description)

另见函数 do_action()


参数(Parameters)

参数 类型 必填 说明
$tag (string) 必需 要执行的操作的名称。
$args (array) 必需 提供给钩住$tag的函数的参数。

返回(Return)

无返回值


源码(Source)

/**
 * Execute functions hooked on a specific action hook, specifying arguments in an array.
 *
 * @since 2.1.0
 *
 * @see do_action() This function is identical, but the arguments passed to the
 *                  functions hooked to $tag< are="" supplied="" using="" an="" array.="" *="" @global="" array="" $wp_filter="" stores="" all="" of="" the="" filters="" *="" @global="" array="" $wp_actions="" increments="" the="" amount="" of="" times="" action="" was="" triggered.="" *="" @global="" array="" $merged_filters="" merges="" the="" filter="" hooks="" using="" this="" function.="" *="" @global="" array="" $wp_current_filter="" stores="" the="" list="" of="" current="" filters="" with="" the="" current="" one="" last="" *="" *="" @param="" string="" $tag="" the="" name="" of="" the="" action="" to="" be="" executed.="" *="" @param="" array="" $args="" the="" arguments="" supplied="" to="" the="" functions="" hooked="" to="" `$tag`.="" */="" function="" do_action_ref_array($tag,="" $args)="" {="" global="" $wp_filter,="" $wp_actions,="" $merged_filters,="" $wp_current_filter;="" if="" (="" !="" isset($wp_actions&#91;$tag&#93;)="" )="" $wp_actions&#91;$tag&#93;="1;" else="" ++$wp_actions&#91;$tag&#93;;="" do="" 'all'="" actions="" first="" if="" (="" isset($wp_filter&#91;'all'&#93;)="" )="" {="" $wp_current_filter&#91;&#93;="$tag;" $all_args="func_get_args();" _wp_call_all_hook($all_args);="" }="" if="" (="" !isset($wp_filter&#91;$tag&#93;)="" )="" {="" if="" (="" isset($wp_filter&#91;'all'&#93;)="" )="" array_pop($wp_current_filter);="" return;="" }="" if="" (="" !isset($wp_filter&#91;'all'&#93;)="" )="" $wp_current_filter&#91;&#93;="$tag;" sort="" if="" (="" !isset(="" $merged_filters&#91;="" $tag="" &#93;="" )="" )="" {="" ksort($wp_filter&#91;$tag&#93;);="" $merged_filters&#91;="" $tag="" &#93;="true;" }="" reset(="" $wp_filter&#91;="" $tag="" &#93;="" );="" do="" {="" foreach(="" (array)="" current($wp_filter&#91;$tag&#93;)="" as="" $the_="" )="" if="" (="" !is_null($the_&#91;'function'&#93;)="" )="" call_user_func_array($the_&#91;'function'&#93;,="" array_slice($args,="" 0,="" (int)="" $the_&#91;'accepted_args'&#93;));="" }="" while="" (="" next($wp_filter&#91;$tag&#93;)="" !="=" false="" );="" array_pop($wp_current_filter);="" }="">
更新版本 源码位置 使用 被使用
2.1.0 wp-includes/plugin.php:517 29 1 function

笔记(Notes)

基本示例

do_action_ref_array() 为WP2原创文章,链接:https://www.wp2.cn/functions/do_action_ref_array/

发表评论

您的电子邮箱地址不会被公开。