Want more features on Pastebin? Sign Up, it's FREE!
Guest

http and https auth

By: a guest on Jan 13th, 2012  |  syntax: PHP  |  size: 0.83 KB  |  views: 78  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class bd_http_https_auth {
  2.         /**
  3.          * @var bd_http_https_auth - Static property to hold our singleton instance
  4.          */
  5.         static $instance = false;
  6.  
  7.         private $_second_auth = false;
  8.  
  9.         private function __construct() {
  10.                 add_action( 'set_auth_cookie', array( $this, 'auth_again' ), null, 5 );
  11.         }
  12.  
  13.         public function auth_again( $auth_cookie, $expire, $expiration, $user_id, $scheme ) {
  14.                 if ( !$this->_second_auth ) {
  15.                         $this->_second_auth = true;
  16.                         wp_set_auth_cookie( $user_id, (bool) $expire, (bool) ( $scheme == 'auth' ) );
  17.                         $this->_second_auth = false;
  18.                 }
  19.         }
  20.  
  21.         /**
  22.          * Function to instantiate our class and make it a singleton
  23.          */
  24.         public static function getInstance() {
  25.                 if ( !self::$instance ) {
  26.                         self::$instance = new self;
  27.                 }
  28.                 return self::$instance;
  29.         }
  30. }
  31. $bd_http_https_auth = bd_http_https_auth::getInstance();
clone this paste RAW Paste Data