woo_sl/cron/schedule_interval

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this page

Name
woo_sl/cron/schedule_interval

Type
Filter

Arguments
(text) $schedule_interval

Description
The filter allows interaction with the default cron schedule interval, which is set to hourly.

Example of usage
As default, the CRON process the expired licences every hour. If require a different interval, the current filter can be used. The following code changes the cron to run every half hour.

        add_filter ('woo_sl/cron/schedule_interval', '_woo_sl_cron_schedule_interval');
    function _woo_sl_cron_schedule_interval( $schedule_interval )
        {
            return 'half_hour';  
        }
    
    //register the custom schedule interval
    //More details at https://developer.wordpress.org/reference/hooks/cron_schedules/
    add_filter( 'cron_schedules',   array( $this, '_woo_sl_cron_custom_schedule_interval' ));
    function _woo_sl_cron_custom_schedule_interval( $schedules )
        {
            $schedules['half_hour'] = array(
                                            'interval'  => 60 * 30,
                                            'display'   => __('Every half hour', 'software-license')
                                        );
            
            return $schedules;   
            
        }


By woocommerce-sl, posted on August 3, 2023

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments