do_action

do_action( string $tag,  $arg = '' )

Execute functions hooked on a specific action hook.

执行特定功能的动作钩子

Description
This function invokes all functions attached to action hook $tag. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the $tag parameter.
You can pass extra arguments to the hooks, much like you can with apply_filters().

描述
这个函数的所有函数invokes行动钩标签附加到美元。它是由可能创建新动作,简单的调用该函数的钩,钩的新指定的名称标签参数使用美元。

额外的参数,你可以传递到了钩,你可以与_状滤波器(应用)。

Parameters #参数Parameters

$tag

(string) (Required) The name of the action to be executed.(必填)钩子的名称

$arg,...

(mixed) (Optional) Additional arguments which are passed on to the functions hooked to the action. Default empty.

这是附加的参数(可选)通过在线的功能钩的动作。默认是空的。


Source #Source

File: wp-includes/plugin.php

421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
function do_action( $tag , $arg = '' ) {
     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 ;
 
     $args = array ();
     if ( is_array ( $arg ) && 1 == count ( $arg ) && isset( $arg [0]) && is_object ( $arg [0]) ) // array(&$this)
         $args [] =& $arg [0];
     else
         $args [] = $arg ;
     for ( $a = 2, $num = func_num_args(); $a < $num ; $a ++ )
         $args [] = func_get_arg( $a );
 
     $wp_filter [ $tag ]->do_action( $args );
 
     array_pop ( $wp_current_filter );
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值