I have a widget
class Xwidget extends WP_Widget{
function cron_addB(){}
}
I want to run a cron job that calls that function from outside the class
function xxx_cron_activation() { ;
if ( !wp_next_scheduled( 'xxx_followers' ) ) {
wp_schedule_event(time(), 'hourly', 'xxx_followers');
}
}
add_action('wp', 'xxx_cron_activation');
add_action('xxx_followers',array('Xwidget',"cron_addB"));
Cron is being triggered but the function is not being executed
1 Answer
Try this instead:
$gloabl $myxclass;
$myxclass = new Xwidget();
add_action( 'xxx_followers', array(&$myxclass, "cron_addB" ) );
or
add_action('xxx_followers', "init_xclass_and_cron");
function init_xclass_and_cron() {
$myxclass = new Xwidget();
$myxclass->cron_addB();
}