wp_unschedule_hook( string $hook )

Unschedules all events attached to the hook.


Description

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


Parameters

$hook

(string) (Required) Action hook, the execution of which will be unscheduled.


Source

File: wp-includes/cron.php

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 );
}


Changelog

Changelog
Version Description
WP-4.9.0 Introduced.