wppaste
WordPress

apply_filters( 'pre_unschedule_hook', null|int|false|WP_Error $pre, string $hook, bool $wp_error )

Since
5.1.0, 5.7.0
Filter to override clearing all events attached to the hook.

Description

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 the number of events successfully unscheduled (zero if no events were registered with the hook). If unscheduling one or more events fails then return either a WP_Error object or false depending on the value of the $wp_error parameter.

Compatibility

WordPress
since 5.7.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Parameters

$prenull|int|false|WP_Error
Value to return instead. Default null to continue unscheduling the hook.
$hookstring
Action hook, the execution of which will be unscheduled.
$wp_errorbool
Whether to return a WP_Error on failure.

Where this hook fires · 1

  • wp-includes/cron.php:700wp_unschedule_hook()

Source code

	 * @since 5.7.0 The `$wp_error` parameter was added, and a WP_Error object can now be returned.	 *	 * @param null|int|false|WP_Error $pre      Value to return instead. Default null to continue unscheduling the hook.	 * @param string                  $hook     Action hook, the execution of which will be unscheduled.	 * @param bool                    $wp_error Whether to return a WP_Error on failure.	 */	$pre = apply_filters( 'pre_unschedule_hook', null, $hook, $wp_error ); 	if ( null !== $pre ) {		if ( $wp_error && false === $pre ) {			return new WP_Error(				'pre_unschedule_hook_false',				__( 'A plugin prevented the hook from being cleared.' )

Changelog

Introduced in 5.1.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.7.0
The $wp_error parameter was added, and a WP_Error object can now be returned.from the docblock
5.1.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.