Skip to content

Instantly share code, notes, and snippets.

@eirichmond
Last active September 17, 2024 01:39
Show Gist options
  • Save eirichmond/9e340f482f2ef1472935b8de6ee2d546 to your computer and use it in GitHub Desktop.
Save eirichmond/9e340f482f2ef1472935b8de6ee2d546 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: ER Post Password Expires
Plugin URI: https://squareone.software
Description: Sets the expiration of a post/page password protected page
Version: 1.0.0
Author: Elliott Richmond
Author URI: https://squareone.software
Text Domain: er-post-password-expires
*/
/**
* Filters post password cookie.
*
* Defaults to 10 days from point of login. For session cookie, return 0.
*
* @since 3.7.0
*
* @param int $expires The expiry time, as passed to setcookie().
*/
add_filter( 'post_password_expires', 'wperss_custom_post_password_expires' );
function wperss_custom_post_password_expires( $expires ) {
return time() + 300; // Expire in 300 seconds, adjust to order
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment