我不是studies development(我只是一个爱好者),但我认为您可以在活动中添加add\\u操作
这只是一份简历。。。
//to the event
if(your_condition)
{
add_action(\'original_event_to_hook\', \'your_scheduled\');
}
function your_scheduled()
{
//create a param here
//And shedule your function with arg
wp_schedule_event(time(), \'hourly\', \'your_function\', array(\'param_1\' => value));
}
function your_function($args){
$verification = $args[\'param_1\'];
if($verification)
{
//OK
//Eventually delete this schedule with this specific arg
}
}
要检索cron“your\\u function”的列表,其中包含以下参数
//Get a filtered list of cron hooks
function kw_filter_crons_hooks($hooks = false, $args = false)
{
$crons = get_option(\'cron\');
if (!$crons)
{
$crons[0] = NULL;
}
$filter = array();
$cronlist = array();
$schedule = array();
foreach($crons as $timestamp => $cron)
{
//@param $hooks = string \'schedule\'
//@param $args = false
//Return an array of cron task sheduled
$schedule[] = $cron;
if(!$schedule && $hooks == \'schedule\' && $args == false)
{
$schedule[0] = NULL;
}
foreach($hooks as $hook)
{
if(isset($cron[$hook]))
{
//@param $hooks = array($hook);
//@param $args = false
//Return an array of cron task sheduled
$cronlist[] = $cron;
if(!$cronlist && is_array($hooks) && $args == false)
{
$cronlist[0] = NULL;
}
if(!empty($args))
{
foreach($cronlist as $key => $value)
{
foreach($value as $k => $v)
{
foreach($v as $x => $y)
{
foreach($args as $arg => $val)
{
if ($y[\'args\'][$arg] == $val)
{
//@param $hooks = array($hook);
//@param $args = array($arg);
//Return an array of cron task specified filtered by arg
$filter[$x] = $y;
if(!$filter && is_array($hooks) && is_array($args))
{
$filter[0] = NULL;
}
}
}
}
}
}
}
}
}
}
if(is_array($hooks) && $args === false && $cronlist)
{
return $cronlist;
}
else if(is_array($hooks) && is_array($args) && $filter)
{
return $filter;
}
else if($hooks === \'schedule\' && $args === false && $schedule)
{
return $schedule;
}
else if($hooks === false && $args === false && $crons)
{
return $crons;
}
else
{
return false;
}
}
//Usage
$cron_filtered = kw_filter_crons_hooks(array(\'your_function\'), array(\'param_1\' => value));
var_dump($cron_filtered);