I am trying understanding how do_action_ref_array() works and the difference between do_action() and do_action_ref_array() . I went through (Difference between do_action_ref_array() and do_action()) and get that do_action_ref_array() is not be used now for custom hooks as do_action() is fine . do_action_ref_array() seems to let us pass an array to the action callback however while playing around with it I found that I am only able to access the first element in the action callback and the other values is'nt available in the callback . Consider :
add_action('wp_footer' , 'rb_action_ref_array');
add_action('testing' , 'testing_ref_array');
function rb_action_ref_array(){
$avar = array(5 , 6) ;
do_action_ref_array('testing' ,$avar );
}
function testing_ref_array($avar){
var_dump ($avar) ;
This var_dumps int(5) all though $avar has 5 , 6 . Similarly , if I use the core action filter pre_get_posts , in my callback I see the WP_Query being directly available though I was assuming an array with value of WP_Query should have been passed
add_action('pre_get_posts' , 'rb_modify_posts');
function rb_modify_posts($query) {
var_dump($query);
}
Var_dumps object(WP_Query)#321 .
My question is how do I access the other values in the array when do_action_ref_array() is used ?