<?php
function plugin_schedules( $schedules ) {
if ( ! isset( $schedules['30sec'] ) ) {
$schedules['30sec'] = array(
'interval' => 30,
'display' => __( 'Once every 30 seconds' )
);
}
return $schedules;
}
add_filter( 'cron_schedules','plugin_schedules' );
if ( ! wp_next_scheduled( 'plugin_cron_hook' ) ) {
wp_schedule_event( time(), '30sec', 'plugin_cron_hook' );
}
add_action( 'plugin_cron_hook', 'plugin_cron_task' );
function plugin_cron_task() {
// Task
}