do_action_ref_array()
最后更新于:2021-11-26 03:01:29
do_action_ref_array( string$hook_name, array$args)Calls the callback functions that have been added to an action hook, specifying arguments in an array.
参数
- $hook_name
-
(string) (Required) The name of the action to be executed.
- $args
-
(array) (Required) The arguments supplied to the functions hooked to
$hook_name
.
源文件
文件: gc-includes/plugin.php
function do_action_ref_array( $hook_name, $args ) {
global $gc_filter, $gc_actions, $gc_current_filter;
if ( ! isset( $gc_actions[ $hook_name ] ) ) {
$gc_actions[ $hook_name ] = 1;
} else {
++$gc_actions[ $hook_name ];
}
// Do 'all' actions first.
if ( isset( $gc_filter['all'] ) ) {
$gc_current_filter[] = $hook_name;
$all_args = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
_gc_call_all_hook( $all_args );
}
if ( ! isset( $gc_filter[ $hook_name ] ) ) {
if ( isset( $gc_filter['all'] ) ) {
array_pop( $gc_current_filter );
}
return;
}
if ( ! isset( $gc_filter['all'] ) ) {
$gc_current_filter[] = $hook_name;
}
$gc_filter[ $hook_name ]->do_action( $args );
array_pop( $gc_current_filter );
}