I need help to run a cron_schedules, actually i develop a plugin that will import woo-commerce product's from xml url. Please review the below code and let me know what is the problem
add_filter( 'cron_schedules', 'woo_add_fively_cron_schedule' );
function woo_add_fively_cron_schedule( $schedules ) {
$schedules['fively'] = array(
'interval' => 300, // Once in Five minutes
'display' => __( 'Once in Five minutes' ),
);
return $schedules;
}
// Schedule an action if it's not already scheduled
if ( ! wp_next_scheduled( 'woo_my_cron_action' ) ) {
wp_schedule_event( time(), 'fively', 'woo_my_cron_action' );
}
// Hook into that action that'll fire weekly
add_action( 'woo_my_cron_action', 'woo_function_to_run' );
function woo_function_to_run() {
// Add some code here
$arr_feed=wp_list_table_import();
$no=20;
echo "aman here";
for ($i=0;$i<count($arr_feed);$i++)
{
$number=get_option('number_product');
if($number)
{
$no=$number;
}
import_product($arr_feed[$i]->url,$no);
}
}
Please review the code or let me know how can i trace the problem.