这个emailer::send 是的函数回调publish_post 行动挂钩。此操作挂钩只接受一个参数,即post ID,它由Wordpress传递。
定义动作挂钩时,需要设置传递给回调函数的参数。例如:
$arg_1 = "The aregument value";
do_action( \'my_custom_action\', $arg_1 );
每次你
my_custom_action, 这个
$arg_1 值自动传递给函数回调。
add_action( \'my_custom_action\', \'my_custom_action_callback\' );
function my_custom_action_callback( $arg_1 ) {
//Do whatever
}
在您所讨论的示例中
publish_post 使用行动挂钩。此操作挂钩接受一个参数,即post ID,并将此参数传递给
emailer:send 由Wordpress自动执行。