wpseek.com
WordPress开发者和主题制作者的搜索引擎



do_action_ref_array › WordPress Function

Since2.1.0
已弃用n/a
do_action_ref_array ( $hook_name, $args )
参数: (2)
  • (string) $hook_name The name of the action to be executed.
    Required: Yes
  • (array) $args The arguments supplied to the functions hooked to `$hook_name`.
    Required: Yes
查看:
定义在:
文档:

Calls the callback functions that have been added to an action hook, specifying arguments in an array.



源码

function do_action_ref_array( $hook_name, $args ) {
	global $wp_filter, $wp_actions, $wp_current_filter;

	if ( ! isset( $wp_actions[ $hook_name ] ) ) {
		$wp_actions[ $hook_name ] = 1;
	} else {
		++$wp_actions[ $hook_name ];
	}

	// Do 'all' actions first.
	if ( isset( $wp_filter['all'] ) ) {
		$wp_current_filter[] = $hook_name;
		$all_args            = func_get_args(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
		_wp_call_all_hook( $all_args );
	}

	if ( ! isset( $wp_filter[ $hook_name ] ) ) {
		if ( isset( $wp_filter['all'] ) ) {
			array_pop( $wp_current_filter );
		}

		return;
	}

	if ( ! isset( $wp_filter['all'] ) ) {
		$wp_current_filter[] = $hook_name;
	}

	$wp_filter[ $hook_name ]->do_action( $args );

	array_pop( $wp_current_filter );
}