wp_nonce_tick( string|int $action = -1 ): float

Returns the time-dependent variable for nonce creation.


Description

A nonce has a lifespan of two ticks. Nonces in their second tick may be updated, e.g. by autosave.


Top ↑

Parameters

$action string|int Optional
The nonce action.

Default: -1


Top ↑

Return

float Float value rounded up to the next highest integer.


Top ↑

Source

File: wp-includes/pluggable.php. View all references

function wp_nonce_tick( $action = -1 ) {
	/**
	 * Filters the lifespan of nonces in seconds.
	 *
	 * @since 2.5.0
	 * @since 6.1.0 Added `$action` argument to allow for more targeted filters.
	 *
	 * @param int        $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day.
	 * @param string|int $action   The nonce action, or -1 if none was provided.
	 */
	$nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action );

	return ceil( time() / ( $nonce_life / 2 ) );
}

Top ↑

Hooks



Top ↑

Changelog

Changelog
Version Description
6.1.0 Added $action argument.
2.5.0 Introduced.

Top ↑

User Contributed Notes

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