<?php
class EM_Trash_Past_Events {
public static function init() {
if( !get_option('dbem_cron_trash_past_events') ){
add_option('dbem_cron_trash_past_events', 1);
}
if( get_option('dbem_cron_trash_past_events', 1) ) {
if( !wp_next_scheduled('emp_cron_process_past_events') ){
$result = wp_schedule_event( time(),'em_minute','emp_cron_process_past_events');
}
add_action('emp_cron_process_past_events', array('EM_Trash_Past_Events','process_past_events') );
}//END - if( get_option('dbem_cron_trash_past_events', 1) )
}
public static function process_past_events(){
global $wpdb;
$EM_Events = EM_Events::get( array( 'scope' => 'past', 'status' => 1 ) );
foreach($EM_Events as $EM_Event){
wp_trash_post($EM_Event->post_id);
}
}
}
add_action('init', array('EM_Trash_Past_Events','init'), 9);
Comments