我试图利用wp_schedule_single_event
计划异步任务。然而,我的事件在60秒后从未被调用。我需要做些什么吗ldp_new_topic_event
在这里使用之前要先钩住它?我的网站正在共享主机上运行。
以下是我如何编码我的时间表:
<?php
if ( !class_exists( \'LDP_Notifications\' ) ) :
final class LDP_Notifications {
public static function new_topic_notification( $topic_id = 0, $forum_id = 0, $anonymous_data = false, $author_id = 0, $is_edit = false) {
// Do some stuff.
// Based on some conditions the following is called:
error_log(\'++++ schedule an event. I see this printed.\');
add_action( \'ldp_new_topic_event\', \'LDP_Notifications::send_push_notification\', 10, 2 );
wp_schedule_single_event( time() + 90, \'ldp_new_topic_event\', array( $message, $deviceTokens ) );
}
public static function send_push_notification( $message, $deviceTokens )
{
error_log(\'Expecting this after 60 seconds but I never got it.\');
}
}
endif;
?>
谢谢你的帮助。