function my_do_action_example(){
$a = array(
'eye patch' => 'yes'
,'parrot' => true
,'wooden leg' => (int) 1
);
$b = 'And hook said: "I ate ice cream with peter pan."';
// Defines the action hook named 'i_am_hook'
do_action( 'i_am_hook', $a, $b );
}
function who_is_hook( $a, $b )
{
echo '<code>';
print_r( $a ); // `print_r` the array data inside the 1st argument
echo '</code>';
echo '<br />fuck you'.$b; // echo linebreak and value of 2nd argument
}
add_action( 'i_am_hook', 'who_is_hook', 10, 2 );
可以通过这个方法调用
<?php my_do_action_example();?>