wp_nonce_tick()
Returns the time-dependent variable for nonce creation.
A nonce has a lifespan of two ticks. Nonces in their second tick may be updated, e.g. by autosave.
This is a pluggable function, and it can be replaced by a plugin. It means that this function is defined (works) only after all plugins are loaded (included), but before this moment this function has not defined. Therefore, you cannot call this and all functions depended on this function directly from a plugin code. They need to be called on plugins_loaded hook or later, for example on init hook.
Function replacement (override) — in a plugin you can create a function with the same name, then it replace this function.
Hooks from the function
Return
float
. Float value rounded up to the next highest integer.
Usage
wp_nonce_tick( $action );
- $action(string|int)
- The nonce action.
Default: -1
Changelog
Since 2.5.0 | Introduced. |
Since 6.1.0 | Added $action argument. |
wp_nonce_tick() wp nonce tick code WP 6.1.1
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 ) ); }