Introduce post_password_expires filter to control the expiration of the post password cookie.
props Viper007Bond for initial patch. fixes #21466. git-svn-id: https://develop.svn.wordpress.org/trunk@25450 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
80b315f740
commit
a58d80bbc1
|
@ -314,8 +314,17 @@ case 'postpass' :
|
||||||
require_once ABSPATH . 'wp-includes/class-phpass.php';
|
require_once ABSPATH . 'wp-includes/class-phpass.php';
|
||||||
$hasher = new PasswordHash( 8, true );
|
$hasher = new PasswordHash( 8, true );
|
||||||
|
|
||||||
// 10 days
|
/**
|
||||||
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
|
* Filter the life of the post password cookie.
|
||||||
|
*
|
||||||
|
* By default, the cookie expires 10 days from now.
|
||||||
|
* To turn this into a session cookie, return 0.
|
||||||
|
*
|
||||||
|
* @since 3.7.0
|
||||||
|
* @param int $expires The expiry time, as passed to setcookie().
|
||||||
|
*/
|
||||||
|
$expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
|
||||||
|
setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH );
|
||||||
|
|
||||||
wp_safe_redirect( wp_get_referer() );
|
wp_safe_redirect( wp_get_referer() );
|
||||||
exit();
|
exit();
|
||||||
|
|
Loading…
Reference in New Issue