do_action_ref_array() - WordPress 函数参考中文文档

返回介绍

do_action_ref_array()

发布于 2017-09-10 字数4511 浏览 868 评论 0

do_action_ref_array( string $tag,  array $args )

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


描述


参数

$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);
}

更新日志

Version 描述
2.1.0 Introduced.

相关函数

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' );
    

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!