SHARE
TWEET

http and https auth

a guest Jan 13th, 2012 113 Never
  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();
RAW Paste Data
Top