public static function generate_html_content()
 {
     require_once NELIOAB_ADMIN_DIR . '/views/account-page.php';
     // Check data against APPENGINE
     $email = NelioABAccountSettings::get_email();
     $reg_num = NelioABAccountSettings::get_reg_num();
     if (NelioABAccountSettings::is_using_free_trial()) {
         $email = '';
         $reg_num = '';
     }
     $sites = array();
     $max_sites = 1;
     try {
         NelioABAccountSettings::check_account_status('now');
     } catch (Exception $e) {
     }
     $current_site_status = NelioABSite::NOT_REGISTERED;
     $error_retrieving_registered_sites = false;
     try {
         $sites_info = NelioABAccountSettings::get_registered_sites_information();
         $max_sites = $sites_info->get_max_sites();
         $sites = $sites_info->get_registered_sites();
         // CHECKING WHETHER WE HAVE INFORMATION ABOUT THIS SITE BEING REGISTERED,
         // EITHER BY ID OR BY URL
         // 1. We check if this user has a registered site whose URL is this site's url
         $registered_site_based_on_url = false;
         foreach ($sites as $site) {
             if ($site->get_url() == get_option('siteurl')) {
                 $registered_site_based_on_url = $site->get_id();
             }
         }
         // 2. We check if the WP installation has a SITE_ID
         // If it does, but it's none of the user's regitered sites,
         // we have a problem, and we'll say the status is INVALID_ID.
         if (NelioABAccountSettings::has_a_configured_site()) {
             $site_id = NelioABAccountSettings::get_site_id();
             $current_site_status = NelioABSite::INVALID_ID;
             foreach ($sites as $site) {
                 if ($site->get_id() == $site_id) {
                     $current_site_status = NelioABSite::ACTIVE;
                 }
             }
         }
         // POSSIBLE RESULTS OF THE PREVIOUS CHECKS:
         // (a) The site is properly registered (== it has a valid ID)
         //if ( NelioABSite::ACTIVE == $current_site_status )
         //	Nothing to do here
         // (b) We have information about an ID that the user, in AE, does not have
         if (NelioABSite::INVALID_ID == $current_site_status) {
             $current_site_status = NelioABSite::NOT_REGISTERED;
             NelioABAccountSettings::fix_registration_info('not-registered');
         }
         // (c) The site is not registered
         if (NelioABSite::NOT_REGISTERED == $current_site_status) {
             if ($registered_site_based_on_url) {
                 $current_site_status = NelioABSite::ACTIVE;
                 NelioABAccountSettings::fix_registration_info('registered', $registered_site_based_on_url);
             }
         }
         // (d) Other scenarios are:
         //   - INACTIVE. We don't care.
         //   - NON_MATCHING_URLS. We no longer use it.
     } catch (Exception $e) {
         $error_retrieving_registered_sites = true;
     }
     // Querying account information
     $user_info = array();
     try {
         $customer_id = NelioABAccountSettings::get_customer_id();
         if (strlen($customer_id) > 0) {
             $url = sprintf(NELIOAB_BACKEND_URL . '/customer/%s', $customer_id);
             $json = NelioABBackend::remote_get($url, true);
             $json = json_decode($json['body']);
             if (isset($user_info['firstname'])) {
                 $user_info['firstname'] = $json->firstname;
             } else {
                 $user_info['firstname'] = '';
             }
             $user_info['subscription_url'] = $json->subscriptionUrl;
             $user_info['subscription_plan'] = $json->subscriptionPlan;
             $user_info['status'] = $json->status;
             $user_info['total_quota'] = intval($json->quotaPerMonth);
             $user_info['quota'] = intval($json->quota + $json->quotaExtra);
         }
         // Agency stuff
         if (isset($json->hasAgency) && $json->hasAgency) {
             $user_info['agency'] = true;
             $user_info['agencyname'] = $json->agencyName;
             $user_info['agencymail'] = $json->agencyEmail;
         } else {
             $user_info['agency'] = false;
             $user_info['agencyname'] = 'Agency Name';
             $user_info['agencymail'] = '*****@*****.**';
         }
     } catch (Exception $e) {
     }
     // Render content
     $title = __('My Account', 'nelioab');
     $view = new NelioABAccountPage($title);
     $view->set_email($email);
     $view->set_email_validity(NelioABAccountSettings::is_email_valid());
     $view->set_reg_num($reg_num);
     $view->set_reg_num_validity(NelioABAccountSettings::is_reg_num_valid());
     $view->set_tac_checked(NelioABAccountSettings::are_terms_and_conditions_accepted());
     $view->set_registered_sites($sites);
     $view->set_max_sites($max_sites);
     $view->set_current_site_status($current_site_status);
     $view->set_user_info($user_info);
     if ($error_retrieving_registered_sites) {
         $view->set_error_retrieving_registered_sites();
     }
     $view->render_content();
     die;
 }