WordPress at a glance

wp_unschedule_hook() WP 1.0

Unschedules all events attached to the hook.

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

Works based on: _set_cron_array()

No Hooks.

Return

Nothing (null).

Usage

wp_unschedule_hook( $hook );
$hook(string) (required)
Action hook, the execution of which will be unscheduled.

Code of wp_unschedule_hook: wp-includes/cron.php VER 4.9.8

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

Related Functions

From tag: cron (schedule)

No comments
    Hello, !     Log In . Register