wp_unschedule_hook( string $hook )

Unschedules all events attached to the hook.


Description Description

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


Parameters Parameters

$hook

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


Top ↑

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

Top ↑

Changelog Changelog

Changelog
Version Description
4.9.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.