WordPress.org

Make WordPress Core

Ticket #18997: #18997.2.patch

File #18997.2.patch, 929 bytes (added by arena, 3 years ago)
  • wp-includes/cron.php

     
    164164                wp_unschedule_event( $timestamp, $hook, $args ); 
    165165} 
    166166 
     167/**  
     168* Unschedule all previously scheduled cron job for a hook.  
     169* 
     170* Can be usefull for plugins when deactivating to clean up the cron queue  
     171*  
     172* The $hook parameter is required, so that the events can be  
     173* identified.  
     174*  
     175* @since 3.4  
     176*  
     177* @param string $hook Action hook, the execution of which will be unscheduled.  
     178*/  
     179function wp_unschedule_hook( $hook ) {  
     180        $crons = _get_cron_array();  
     181        foreach( $crons as $timestamp => $args ) {  
     182                unset( $crons[$timestamp][$hook] );  
     183                if ( empty( $crons[$timestamp] ) ) 
     184                        unset( $crons[$timestamp] );  
     185        }  
     186        _set_cron_array( $crons );  
     187}  
     188 
    167189/** 
    168190 * Retrieve the next timestamp for a cron event. 
    169191 *