On this page
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.
Parameters
$actionstring|int Optional-
The nonce action.
Default:
-1
Return
float Float value rounded up to the next highest integer.
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 ) );
}
Hooks
- apply_filters( 'nonce_life',
int $lifespan ,string|int $action ) -
Filters the lifespan of nonces in seconds.
Related
Uses
| Uses | Description |
|---|---|
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| wp_verify_nonce() wp-includes/pluggable.php | Verifies that a correct security nonce was used with time limit. |
| wp_create_nonce() wp-includes/pluggable.php | Creates a cryptographic token tied to a specific action, user, user session, and window of time. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_nonce_tick