| | 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 | */ |
| | 179 | function 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 | |