返回介绍

do_action_ref_array()

发布于 2017-09-10 22:15:34 字数 4512 浏览 1044 评论 0 收藏 0

do_action_ref_array( string $tag,  array $args )

Execute functions hooked on a specific action hook, specifying arguments in an array.


description


参数

$tag

(string) (Required) The name of the action to be executed.

$args

(array) (Required) The arguments supplied to the functions hooked to $tag.


源代码

File: wp-includes/plugin.php

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

	if ( ! isset($wp_actions[$tag]) )
		$wp_actions[$tag] = 1;
	else
		++$wp_actions[$tag];

	// Do 'all' actions first
	if ( isset($wp_filter['all']) ) {
		$wp_current_filter[] = $tag;
		$all_args = func_get_args();
		_wp_call_all_hook($all_args);
	}

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

	if ( !isset($wp_filter['all']) )
		$wp_current_filter[] = $tag;

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

	array_pop($wp_current_filter);
}

更新日志

Versiondescription
2.1.0Introduced.

相关函数

Uses

  • wp-includes/plugin.php: _wp_call_all_hook()

Used By

  • wp-includes/class-wp-http-requests-hooks.php: WP_HTTP_Requests_Hooks::dispatch()
  • wp-includes/class-wp-network-query.php: WP_Network_Query::get_networks()
  • wp-includes/class-wp-network-query.php: WP_Network_Query::parse_query()
  • wp-includes/class-wp-site-query.php: WP_Site_Query::get_sites()
  • wp-includes/class-wp-site-query.php: WP_Site_Query::parse_query()
  • wp-includes/plugin.php: do_action_deprecated()
  • wp-includes/class-wp-comment-query.php: WP_Comment_Query::get_comments()
  • wp-includes/class-wp-comment-query.php: WP_Comment_Query::parse_query()
  • wp-includes/class-wp-query.php: WP_Query::setup_postdata()
  • wp-admin/includes/deprecated.php: WP_User_Search::prepare_query()
  • wp-admin/includes/user.php: edit_user()
  • wp-includes/class.wp-styles.php: WP_Styles::__construct()
  • wp-includes/pluggable.php: wp_mail()
  • wp-includes/class-wp.php: WP::main()
  • wp-includes/class-wp.php: WP::parse_request()
  • wp-includes/class-wp.php: WP::send_headers()
  • wp-includes/class-wp-query.php: WP_Query::the_post()
  • wp-includes/class-wp-query.php: WP_Query::have_posts()
  • wp-includes/class-wp-query.php: WP_Query::get_posts()
  • wp-includes/class-wp-query.php: WP_Query::parse_query()
  • wp-includes/class-wp-http-curl.php: WP_Http_Curl::request()
  • wp-includes/admin-bar.php: wp_admin_bar_render()
  • wp-includes/feed.php: fetch_feed()
  • wp-includes/class-wp-user-query.php: WP_User_Query::prepare_query()
  • wp-includes/user.php: wp_signon()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::rewrite_rules()
  • wp-includes/class.wp-scripts.php: WP_Scripts::init()
  • wp-includes/class-wp-widget.php: WP_Widget::form_callback()
  • wp-includes/comment.php: pingback()
  • Show 24 more used by Hide more used by

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Basic Example
    Call an action and pass an array of arguments:

    
    $args = array( 'arg_1', true, 'foo', 'arg_4' );
    do_action_ref_array( 'my_action', $args );
    

    This is the same as:

    
    do_action( 'my_action', 'arg_1', true, 'foo', 'arg_4' );
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文