| | 186 | /** |
| | 187 | * Unschedule all previously scheduled cron jobs for a hook. |
| | 188 | * |
| | 189 | * Can be useful for plugins when deactivating to clean up the cron queue |
| | 190 | * |
| | 191 | * The $hook parameter is required, so that the events can be |
| | 192 | * identified. |
| | 193 | * |
| | 194 | * @since x.x |
| | 195 | * |
| | 196 | * @param string $hook Action hook, the execution of which will be unscheduled. |
| | 197 | */ |
| | 198 | function wp_unschedule_hook( $hook ) { |
| | 199 | |
| | 200 | $crons = _get_cron_array(); |
| | 201 | |
| | 202 | foreach( $crons as $timestamp => $args ) { |
| | 203 | |
| | 204 | unset( $crons[$timestamp][$hook] ); |
| | 205 | |
| | 206 | if ( empty( $crons[$timestamp] ) ) { |
| | 207 | unset( $crons[$timestamp] ); |
| | 208 | } |
| | 209 | |
| | 210 | } |
| | 211 | |
| | 212 | _set_cron_array( $crons ); |
| | 213 | |
| | 214 | } |
| | 215 | |