/**
  * Adds sticky admin message.
  *
  * @author Vova Feldman (@svovaf)
  * @since  1.1.0
  *
  * @param string $message
  * @param string $id
  * @param string $title
  * @param string $type
  */
 function add_sticky_admin_message($message, $id, $title = '', $type = 'success')
 {
     $this->_admin_notices->add_sticky($message, $id, $title, $type);
 }
 function rw_reset_account()
 {
     global $rw_fs;
     $rw_account = rw_account();
     $rw_api = rwapi();
     // Before making any changes, make sure site credentials are good.
     // Preserve previous credentials.
     $prev_site_id = $rw_account->site_id;
     $prev_site_public_key = $rw_account->site_public_key;
     $prev_site_secret_key = $rw_account->site_secret_key;
     // Get install information from request.
     $site_id = rw_request_get('site_id');
     $site_public_key = rw_request_get('site_public_key');
     $site_secret_key = rw_request_get('site_secret_key');
     $admin_notices = FS_Admin_Notice_Manager::instance(WP_RW__ID, 'Rating-Widget');
     if (!is_numeric($site_id)) {
         $admin_notices->add('Invalid site ID. Please contact our support for more details.');
         return false;
     }
     if (32 !== strlen($site_public_key)) {
         $admin_notices->add('Invalid public key. Please contact our support for more details.');
         return false;
     }
     if (20 > strlen($site_secret_key)) {
         $admin_notices->add('Invalid secret key. Please contact our support for more details.');
         return false;
     }
     // Override site details.
     $rw_account->set_site($site_id, $site_public_key, $site_secret_key, false);
     // Reload API with new account details.
     $rw_api->reload();
     if (!$rw_api->test()) {
         // Fallback to previous account.
         $rw_account->set_site($prev_site_id, $prev_site_public_key, $prev_site_secret_key, false);
         // Reload API with new account details.
         $rw_api->reload();
         $admin_notices->add('Invalid site credentials. Failed pining RatingWidget\'s API. Please contact our support for more details.');
         return false;
     }
     // Save new RW credentials.
     $rw_account->save();
     if ($rw_fs->is_registered()) {
         // Send uninstall event.
         $rw_fs->_uninstall_plugin_event(false);
         if ('true' === rw_request_get('delete_account')) {
             $rw_fs->delete_account_event(false);
         }
     }
     if (rw_migration_to_freemius()) {
         fs_redirect($rw_fs->_get_admin_page_url('account'));
         die;
     }
     return true;
 }