Many of us may get confused when using do_action and do_action_ref_array hooks as they both looks identical. But, there must be something different for both this hooks when comes to implementation and yes they do. Lets know what make them different from one another.
do_action
In one of my previous article on do_action I have explained what is the use of do_action.
do_action allows you to create a new action. This is much like apply_filters() with the exception that nothing is returned and only the functions or methods are called.
With single argument
do_action( $tag, $arg );
With multiple arguments:
do_action( $tag, $arg_a, $arg_b, $etc );
do_action_ref_array
This function is identical to do_action, but the only difference is that the arguments passed to the functions hooked to $tag are supplied using an array.
$args = array( 'arg_1', true, 'foo', 'arg_4' );
do_action_ref_array( $tag, $args );
do_action
In one of my previous article on do_action I have explained what is the use of do_action.
do_action allows you to create a new action. This is much like apply_filters() with the exception that nothing is returned and only the functions or methods are called.
With single argument
do_action( $tag, $arg );
With multiple arguments:
do_action( $tag, $arg_a, $arg_b, $etc );
do_action_ref_array
This function is identical to do_action, but the only difference is that the arguments passed to the functions hooked to $tag are supplied using an array.
$args = array( 'arg_1', true, 'foo', 'arg_4' );
do_action_ref_array( $tag, $args );
No comments:
Post a Comment