public static function deleteTransient($key)
 {
     $transient_settings = RublonHelper::getSettings('transient');
     if (!empty($transient_settings[$key])) {
         unset($transient_settings[$key]);
         RublonHelper::saveSettings($transient_settings, 'transient');
     }
 }
 /**
  * Update Rublon plugin settings using 'systemToken' and 'secretKey' from
  * successfully registered project
  */
 private function updateRublonSettings()
 {
     $settings = RublonHelper::getSettings();
     $settings['rublon_system_token'] = $this->getSystemToken();
     $settings['rublon_secret_key'] = $this->getSecretKey();
     $this->_clearConfig();
     RublonHelper::saveSettings($settings, 'main');
     do_action('rublon_save_settings', $settings, 'main');
 }
 private function removeOldRublonTransients()
 {
     $transient_settings = RublonHelper::getSettings('transient');
     $new_transient_settings = array();
     foreach ($transient_settings as $key => $setting) {
         if ($setting[Rublon_Transients::EXPIRES_KEY] >= time()) {
             $new_transient_settings[$key] = $setting;
         }
     }
     RublonHelper::saveSettings($new_transient_settings, 'transient');
 }
function rublon2factor_anonymous_stats_agreement()
{
    $post = $_POST;
    $other_settings = RublonHelper::getSettings('other');
    if (!empty($post['nonce']) && wp_verify_nonce($post['nonce'], Rublon_Pointers::ANONYMOUS_STATS_ALLOWED)) {
        $other_settings[Rublon_Pointers::ANONYMOUS_STATS_ALLOWED] = $post['answer'];
        RublonHelper::saveSettings($other_settings, 'other');
        if ($post['answer'] == RublonHelper::YES) {
            try {
                RublonHelper::notify(array('msg' => 'Preliminary statistics from a WordPress site.'), array('message-type' => RublonHelper::RUBLON_NOTIFY_TYPE_STATS));
            } catch (Exception $e) {
                // Do nothing.
            }
        }
    }
}
 /**
  * Perform single site registration.
  * 
  * Register one of network's sites in Rublon and save
  * System Token and Secret Key into the site's individual
  * options table. 
  * 
  * @param WP_User $user WordPress user object
  * @return boolean True if registration was successful
  */
 public static function performSiteRegistration()
 {
     try {
         require_once dirname(__FILE__) . '/libs/RublonImplemented/RublonSubprojectRegistrationWordPress.php';
         // Create a RublonSubprojectRegistration instance
         // and register the site
         $site_registration = new RublonSubprojectRegistrationWordPress();
         $response = $site_registration->register();
         // Save the received settings upon success
         $settings = RublonHelper::getSettings();
         $settings['rublon_system_token'] = $response['system_token'];
         $settings['rublon_secret_key'] = $response['secret_key'];
         RublonHelper::saveSettings($settings);
     } catch (Exception $e) {
         // Cannot register the site
         return false;
     }
     return !empty($response);
 }