Esempio n. 1
0
 static function &init()
 {
     static $instance = false;
     if (!$instance) {
         $class = get_called_class();
         $services = Keyring::get_registered_services();
         if (in_array($class::NAME, array_keys($services))) {
             $instance = $services[$class::NAME];
         } else {
             $instance = new $class();
             Keyring::register_service($instance);
         }
     }
     return $instance;
 }
Esempio n. 2
0
 /**
  * Core request handler which is the crux of everything. An action is called
  * here for almost everything Keyring does, so you can use it to intercept
  * almost everything. Based entirely on $_REQUEST[page|action|service]
  */
 static function request_handlers()
 {
     global $current_user;
     if (defined('KEYRING__FORCE_USER') && KEYRING__FORCE_USER && in_array($_REQUEST['action'], array('request', 'verify'))) {
         global $current_user;
         $real_user = $current_user->ID;
         wp_set_current_user(KEYRING__FORCE_USER);
     }
     if (!empty($_REQUEST['action']) && in_array($_REQUEST['action'], apply_filters('keyring_core_actions', array('request', 'verify', 'created', 'delete', 'manage'))) && !empty($_REQUEST['service']) && in_array($_REQUEST['service'], array_keys(Keyring::get_registered_services()))) {
         // We have an action here to allow us to do things pre-authorization, just in case
         do_action("pre_keyring_{$_REQUEST['service']}_{$_REQUEST['action']}", $_REQUEST);
         // Core nonce check required for everything. "keyring-ACTION" is the kr_nonce format
         if (!isset($_REQUEST['kr_nonce']) || !wp_verify_nonce($_REQUEST['kr_nonce'], 'keyring-' . $_REQUEST['action'])) {
             Keyring::error(__('Invalid/missing Keyring core nonce. All core actions require a valid nonce.', 'keyring'));
             exit;
         }
         Keyring_Util::debug("keyring_{$_REQUEST['service']}_{$_REQUEST['action']}");
         Keyring_Util::debug($_GET);
         do_action("keyring_{$_REQUEST['service']}_{$_REQUEST['action']}", $_REQUEST);
         if ('delete' == $_REQUEST['action']) {
             do_action("keyring_connection_deleted", $_REQUEST['service'], $_REQUEST);
         }
     }
     if (defined('KEYRING__FORCE_USER') && KEYRING__FORCE_USER && in_array($_REQUEST['action'], array('request', 'verify'))) {
         wp_set_current_user($real_user);
     }
 }