I have some programming error in my wordpress plugin. When its running, then it keeps registering cron job to the wordpress. I wrote the plugin as a class:

class Cleverstart_Woofio extends WC_Integration{
    public function __construct(){
       add_action('woofio_hourly', array( $this,'woofio_create_haystack'));
       wp_schedule_event(time(), 'hourly', 'woofio_hourly');
       //other stuff not related to the question

   public function woofio_create_haystack(){
     //do quite performance heavy stuff


$cleverstart_woofio = new Cleverstart_Woofio();

My theory is, that the new Cleverstart_Woofio(); call will always schedule new cron event, clugging my site. I need to check if the event was already scheduled and schedule it only once. However, I am clueless on how to achieve this.

Thanks for help


Have you ever heard of Rubber Ducking?

The official documentation has an answer:

if ( ! wp_next_scheduled( 'woofio_hourly' ) ) {
    wp_schedule_event( time(), 'hourly', 'woofio_hourly' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.