我正在使用wordpress的插件,我需要使用单个事件调度程序更新数据库选项,但它似乎没有触发 . 我的代码:

function task_to_perform()
{
    update_option( "number_of_cubes", 50);
    wp_unschedule_event('lalala_hook');
}

add_action( 'lalala_hook','task_to_perform' );

function some_other_function()
{
    if ( !wp_next_scheduled( 'lalala_hook' ) )
        wp_schedule_single_event( time() + 10, 'lalala_hook' );
}

所以当我调用 some_other_function(); 时,我希望wordpress从现在开始设置10秒的计划时间,以更新选项"number_of_cubes" .

此选项在插件中定义如下:

register_setting("stars_settings", "number_of_cubes");

if (!get_option( "number_of_cubes"))
    update_option( "number_of_cubes", 0);