A WordPress-centric search engine for devs and theme authors



wp_unschedule_hook ›

Since4.9.0
Deprecatedn/a
wp_unschedule_hook ( $hook )
Parameters:
  • (string) $hook Action hook, the execution of which will be unscheduled.
    Required: Yes
Defined at:
Codex:

Unschedules all events attached to the hook.

Can be useful for plugins when deactivating to clean up the cron queue.



Source

function wp_unschedule_hook( $hook ) {
	$crons = _get_cron_array();

	foreach ( $crons as $timestamp => $args ) {
		unset( $crons[ $timestamp ][ $hook ] );

		if ( empty( $crons[ $timestamp ] ) ) {
			unset( $crons[ $timestamp ] );
		}
	}

	_set_cron_array( $crons );
}