[wp-trac] [WordPress Trac] #25266: wp_unschedule_event should apply filter to changes

WordPress Trac noreply at wordpress.org
Mon Sep 9 15:38:15 UTC 2013


#25266: wp_unschedule_event should apply filter to changes
-------------------------+-----------------------------
 Reporter:  _ck_         |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Cron         |    Version:
 Severity:  major        |   Keywords:
-------------------------+-----------------------------
 wp_unschedule_event needs to announce removal of events, just like
 wp_schedule_event does through a filter

 I would suggest allowing the filter to cancel the unschedule as a bonus.

 ie.
 {{{
 function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
         $crons = _get_cron_array();
         $key = md5(serialize($args));
         $event = (object) array( 'hook' => $hook, 'timestamp' =>
 $timestamp, 'args' => $args );
         if ( apply_filters('unschedule_event', $event) )
                 unset( $crons[$timestamp][$hook][$key] );
         if ( empty($crons[$timestamp][$hook]) )
                 unset( $crons[$timestamp][$hook] );
         if ( empty($crons[$timestamp]) )
                 unset( $crons[$timestamp] );
         _set_cron_array( $crons );
 }
 }}}

 Optionally, consider if the filter returns false and there is no unset,
 the database should not be rewritten.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/25266>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list