public function displayAccountsPage() { // handle actions and show notes $this->handleActions(); if ($this->requestAction() == 'save_account') { $this->saveAccount(); } if ($this->requestAction() == 'edit_account') { return $this->displayEditAccountsPage(); } if ($default_account_id = get_option('wplister_default_account_id')) { $default_account = WPLE_eBayAccount::getAccount($default_account_id); if (!$default_account) { $this->showMessage(__('Your default account does not exist anymore. Please select a new default account.', 'wplister'), 1); } else { // make sure the eBay token stored in wp_options matches the default account $ebay_token_v1 = get_option('wplister_ebay_token'); if ($ebay_token_v1 != $default_account->token) { // update_option( 'wplister_ebay_token', $default_account->token ); $this->makeDefaultAccount($default_account->id); // update everything, including expiration time $this->showMessage(__('A new eBay token was found and your default account has been updated accordingly.', 'wplister'), 2); } } } // refresh enabled sites automatically for now $this->fixEnabledSites(); // check for data linked to deleted accounts WPL_Setup::checkDbForInvalidAccounts(); // create table and fetch items to show $this->accountsTable = new WPLE_AccountsTable(); $this->accountsTable->prepare_items(); $form_action = 'admin.php?page=' . self::ParentMenuId . '-settings' . '&tab=accounts'; if (@$_REQUEST['page'] == 'wplister-settings-accounts') { $form_action = 'admin.php?page=wplister-settings-accounts'; } $active_tab = 'accounts'; $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'accountsTable' => $this->accountsTable, 'ebay_accounts' => WPLE_eBayAccount::getAll(true), 'ebay_sites' => EbayController::getEbaySites(), 'active_ebay_sites' => WPLE_eBaySite::getAll(), 'default_account' => get_option('wplister_default_account_id'), 'settings_url' => 'admin.php?page=' . self::ParentMenuId . '-settings', 'auth_url' => $form_action . '&action=wplRedirectToAuthURL', 'form_action' => $form_action); $this->display('settings_accounts', $aData); }