nonce_life
Filter HookDescription
Filters the lifespan of nonces in seconds.Hook Information
File Location |
wp-includes/pluggable.php
View on GitHub
|
Hook Type | Filter |
Line Number | 2349 |
Hook Parameters
Type | Name | Description |
---|---|---|
int
|
$lifespan
|
Lifespan of nonces in seconds. Default 86,400 seconds, or one day. |
string|int
|
$action
|
The nonce action, or -1 if none was provided. |
Usage Examples
Basic Usage
<?php
// Hook into nonce_life
add_filter('nonce_life', 'my_custom_filter', 10, 2);
function my_custom_filter($lifespan, $action) {
// Your custom filtering logic here
return $lifespan;
}
Source Code Context
wp-includes/pluggable.php:2349
- How this hook is used in WordPress core
<?php
2344 * @since 6.1.0 Added `$action` argument to allow for more targeted filters.
2345 *
2346 * @param int $lifespan Lifespan of nonces in seconds. Default 86,400 seconds, or one day.
2347 * @param string|int $action The nonce action, or -1 if none was provided.
2348 */
2349 $nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS, $action );
2350
2351 return ceil( time() / ( $nonce_life / 2 ) );
2352 }
2353 endif;
2354
PHP Documentation
<?php
/**
* 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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/pluggable.php
Related Hooks
Related hooks will be displayed here in future updates.