函数文档

_wp_call_all_hook()

💡 云策文档标注

概述

_wp_call_all_hook() 是 WordPress 内部函数,用于调用 'all' 钩子,处理所有已挂载到该钩子的函数。它主要用于 apply_filters()、do_action() 和 do_action_ref_array() 的内部实现,不建议外部直接使用。

关键要点

  • 函数调用 'all' 钩子,传递调用钩子的所有参数。
  • 内部使用于 apply_filters()、do_action() 和 do_action_ref_array(),外部使用可能导致失败。
  • 不检查 'all' 钩子是否存在,调用前需确保钩子已存在。
  • 参数 $args 为必需数组,包含调用钩子的收集参数。

代码示例

function _wp_call_all_hook( $args ) {
	global $wp_filter;

	$wp_filter['all']->do_all_hook( $args );
}

注意事项

  • 此函数为内部实现,外部直接调用可能不可靠,应通过标准钩子函数使用。
  • 确保 'all' 钩子在调用前已定义,否则函数会失败。

📄 原文内容

Calls the ‘all’ hook, which will process the functions hooked into it.

Description

The ‘all’ hook passes all of the arguments or parameters that were used for the hook, which this function was called for.

This function is used internally for apply_filters() , do_action() , and do_action_ref_array() and is not meant to be used from outside those functions. This function does not check for the existence of the all hook, so it will fail unless the all hook exists prior to this function call.

Parameters

$argsarrayrequired
The collected parameters from the hook that was called.

Source

function _wp_call_all_hook( $args ) {
	global $wp_filter;

	$wp_filter['all']->do_all_hook( $args );
}

Changelog

Version Description
2.5.0 Introduced.