Setting time limit for the password pages.
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 24 Aug 2017 12:41:11 +0000 (08:41 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 24 Aug 2017 12:41:11 +0000 (08:41 -0400)
If the page is password protected then set the timeout for the cookie to
60 minutes.

functions.php
style.css

index b159b2b..6eaf7e7 100644 (file)
@@ -169,4 +169,14 @@ function glm_get_header() {
 
 
 add_action('wp_enqueue_scripts', 'glm_site_scripts');
+add_action( 'wp', 'post_pw_sess_expire' );
+function post_pw_sess_expire() {
+    global $post;
+    if ( post_password_required() ) {
+        if ( isset( $_COOKIE['wp-postpass_' . COOKIEHASH] )) {
+            // Setting a time of 0 in setcookie() forces the cookie to expire with the session
+            setcookie('wp-postpass_' . COOKIEHASH, $_COOKIE['wp-postpass_' . COOKIEHASH], strtotime( '+60 minutes' ), COOKIEPATH);
+        }
+    }
+}
 ?>
index cf1a3ca..77ede02 100644 (file)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: Adeline-Construction
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme for Adeline Construction
-Version: 1.0.3
+Version: 1.0.4
 */