apply_filters_ref_array()
最后更新于:2021-11-25 19:49:13
apply_filters_ref_array( string$hook_name, array$args)Calls the callback functions that have been added to a filter hook, specifying arguments in an array.
参数
- $hook_name
-
(string) (Required) The name of the filter hook.
- $args
-
(array) (Required) The arguments supplied to the functions hooked to
$hook_name
.
响应
(mixed) The filtered value after all hooked functions are applied to it.
源文件
文件: gc-includes/plugin.php
function apply_filters_ref_array( $hook_name, $args ) {
global $gc_filter, $gc_current_filter;
// 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 $args[0];
}
if ( ! isset( $gc_filter['all'] ) ) {
$gc_current_filter[] = $hook_name;
}
$filtered = $gc_filter[ $hook_name ]->apply_filters( $args[0], $args );
array_pop( $gc_current_filter );
return $filtered;
}