Shorter Nonce Lifetime
Makes WordPress security tokens (nonces) expire after 4 hours instead of up to 24, shrinking the window in which a leaked link can be reused.
Opens WPIDE on
Code
// Lifetime in seconds. A nonce stays valid for between half and all of this time.
$wpide_nonce_life = 4 * HOUR_IN_SECONDS;
add_filter( 'nonce_life', function () use ( $wpide_nonce_life ) {
return $wpide_nonce_life;
} );
Notes
Pages left open longer than this may show "The link you followed has expired" on submit; cached pages with forms are affected too.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.