Guest User

Untitled

a guest
Apr 27th, 2017
271
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if ( isset ($_POST['post_password'] ) ) custom_postpass_check();
  2.  
  3. function custom_password_form( $out ) {
  4. $out = str_replace('wp-login.php', '', $out);
  5. return $out;
  6. }
  7. add_filter( 'the_password_form', 'custom_password_form', 10, 1 );
  8.  
  9. function custom_postpass_check(){
  10. $secure = ( 'https' === parse_url( wp_login_url(), PHP_URL_SCHEME ) );
  11. if ( ! array_key_exists( 'post_password', $_POST ) ) {
  12. wp_safe_redirect( wp_get_referer() );
  13. exit();
  14. }
  15.  
  16. $hasher = new PasswordHash( 8, true );
  17.  
  18. $expire = apply_filters( 'post_password_expires', time() + 10 * DAY_IN_SECONDS );
  19. $referer = wp_get_referer();
  20. if ( $referer ) {
  21. $secure = ( 'https' === parse_url( $referer, PHP_URL_SCHEME ) );
  22. } else {
  23. $secure = false;
  24. }
  25. setcookie( 'wp-postpass_' . COOKIEHASH, $hasher->HashPassword( wp_unslash( $_POST['post_password'] ) ), $expire, COOKIEPATH, COOKIE_DOMAIN, $secure );
  26.  
  27. wp_safe_redirect( wp_get_referer() );
  28. exit();
  29. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×