Created
September 4, 2012 09:54
-
-
Save tott/3619324 to your computer and use it in GitHub Desktop.
wp-pass.php replacement for wp > 3.4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'plugins_loaded', 'bypass_wp_login_for_pw_protected_posts' ); | |
function bypass_wp_login_for_pw_protected_posts() { | |
// this functionality is a fork of http://core.trac.wordpress.org/browser/trunk/wp-login.php#L385 | |
// keep this in sync with Core | |
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'login'; | |
if ( 'postpass' <> $action ) | |
return; | |
if ( empty( $wp_hasher ) ) { | |
require_once( ABSPATH . 'wp-includes/class-phpass.php' ); | |
// By default, use the portable hash from phpass | |
$wp_hasher = new PasswordHash(8, true); | |
} | |
// 10 days | |
setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 864000, COOKIEPATH ); | |
wp_safe_redirect( wp_get_referer() ); | |
exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment