• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress core a2z

WordPress core a2z

WordPress core only

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / wp_unschedule_event() – Unschedule a previously scheduled event.

You appear to be a bot. Output may be restricted

Description

Unschedule a previously scheduled event.

The $timestamp and $hook parameters are required so that the event can be identified.

Usage

$bool = wp_unschedule_event( $timestamp, $hook, $args );

Parameters

$timestamp
( int ) required – Unix timestamp (UTC) of the event.
$hook
( string ) required – Action hook of the event.
$args
( array ) optional – Optional. Array containing each separate argument to pass to the hook's callback function. Although not passed to a callback, these arguments are used to uniquely identify the event, so they should be the same as those used when originally scheduling the event.

Returns

bool True if event successfully unscheduled. False for failure.

Source

File name: wordpress/wp-includes/cron.php
Lines:

1 to 38 of 38
function wp_unschedule_event( $timestamp, $hook, $args = array() ) {
  // Make sure timestamp is a positive integer.
  if ( ! is_numeric( $timestamp ) || $timestamp <= 0 ) {
    return false;
  }

  
/**
 * Filter to preflight or hijack unscheduling of events.
 *
 * Returning a non-null value will short-circuit the normal unscheduling
 * process, causing the function to return the filtered value instead.
 *
 * For plugins replacing wp-cron, return true if the event was successfully
 * unscheduled, false if not.
 *
 * @since 5.1.0
 *
 * @param null|bool $pre       Value to return instead. Default null to continue unscheduling the event.
 * @param int       $timestamp Timestamp for when to run the event.
 * @param string    $hook      Action hook, the execution of which will be unscheduled.
 * @param array     $args      Arguments to pass to the hook's callback function.
 */
  $pre = apply_filters( 'pre_unschedule_event', null, $timestamp, $hook, $args );
  if ( null !== $pre ) {
    return $pre;
  }

  $crons = _get_cron_array();
  $key   = md5( serialize( $args ) );
  unset( $crons[ $timestamp ][ $hook ][ $key ] );
  if ( empty( $crons[ $timestamp ][ $hook ] ) ) {
    unset( $crons[ $timestamp ][ $hook ] );
  }
  if ( empty( $crons[ $timestamp ] ) ) {
    unset( $crons[ $timestamp ] );
  }
  return _set_cron_array( $crons );
}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 2nd April 2020

Primary Sidebar

Information

Function name: wp_unschedule_event
Plugin ref: WordPress
Version: 5.6
Sourcefile: wp-includes/cron.php
File ref: wp-includes/cron.php
Deprecated?: No
API Letters: E,U,W

Footer

WP-a2z
WordPress core a2z
WordPress core only
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  core.wp-a2z.org
© Copyright WP-a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites