コード例 #1
0
ファイル: WPL_Core.php プロジェクト: booklein/wpbookle
 public function initEC($account_id = null, $site_id = null)
 {
     // make sure the database is up to date
     WPLE_UpgradeHelper::maybe_upgrade_db();
     // init controller
     $this->EC = new EbayController();
     // use current default account by default (WPL1)
     $ebay_site_id = self::getOption('ebay_site_id');
     $sandbox_enabled = self::getOption('sandbox_enabled');
     $ebay_token = self::getOption('ebay_token');
     // set site_id dynamically during authentication
     // if ( isset( $_REQUEST['site_id'] ) && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'wplRedirectToAuthURL' ) {
     if (isset($_REQUEST['site_id']) && isset($_REQUEST['sandbox'])) {
         $ebay_site_id = $_REQUEST['site_id'];
         $sandbox_enabled = $_REQUEST['sandbox'];
         $ebay_token = '';
     }
     // use specific account if provided in request or parameter
     if (!$account_id && isset($_REQUEST['account_id'])) {
         $account_id = $_REQUEST['account_id'];
     }
     if ($account_id) {
         // $account = new WPLE_eBayAccount( $account_id ); // not suitable to check if an account exists
         $account = WPLE_eBayAccount::getAccount($account_id);
         if ($account) {
             $ebay_site_id = $account->site_id;
             $sandbox_enabled = $account->sandbox_mode;
             $ebay_token = $account->token;
         } else {
             $msg = sprintf('<b>Warning: You are trying to use an account which does not exist in WP-Lister</b> (ID %s).', $account_id) . '<br>';
             $msg .= 'This can happen when you delete an account from WP-Lister without removing all listings, profiles and orders first.' . '<br><br>';
             $msg .= 'In order to solve this issue, please visit your account settings and follow the instructions to assign all listings, orders and profiles to your default account.';
             wple_show_message($msg, 'warn');
         }
     } else {
         $account_id = get_option('wplister_default_account_id');
     }
     if ($site_id) {
         $ebay_site_id = $site_id;
     }
     $this->EC->initEbay($ebay_site_id, $sandbox_enabled, $ebay_token, $account_id);
 }
コード例 #2
0
ファイル: ToolsPage.php プロジェクト: booklein/wpbookle
 public function upgradeTablesUTF8MB4()
 {
     global $wpdb;
     // get list of our tables
     $tables = $wpdb->get_col("SHOW TABLES LIKE '{$wpdb->prefix}ebay_%'");
     if (empty($tables)) {
         wple_show_message('no tables found.', 'error');
         return;
     }
     // convert all tables
     foreach ($tables as $table) {
         $converted = WPLE_UpgradeHelper::convert_custom_table_to_utf8mb4($table);
         if ($converted) {
             wple_show_message('Table <i>' . $table . '</i> was converted.');
         } else {
             wple_show_message('Table <i>' . $table . '</i> was not converted.', 'error');
         }
     }
 }
コード例 #3
0
ファイル: WPL_Setup.php プロジェクト: booklein/wpbookle
 public function checkSetup($page = false)
 {
     global $pagenow;
     // check if safe mode is enabled
     $this->isPhpSafeMode();
     // check if incomatible plugins are active
     $this->checkPlugins();
     // check if a recent version of WooCommerce is installed
     $this->checkWooCommerce();
     // check if cURL is loaded
     if (!$this->isCurlLoaded()) {
         return false;
     }
     // check for windows server
     // if ( $this->isWindowsServer() ) return false;
     $this->isWindowsServer($page);
     // create folders if neccessary
     if ($this->checkFolders()) {
         return false;
     }
     // check for updates
     $this->checkForUpdates();
     // check if cron is working properly
     $this->checkCron();
     // check if any sites need to be refreshed
     $this->checkSites();
     // check database after migration
     // $this->checkDatabase();
     // $this->checkDbForInvalidAccounts();
     // check for multisite installation
     // if ( $this->checkMultisite() ) return false;
     $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : false;
     // setup wizard
     // if ( self::getOption('ebay_token') == '' ) {
     if ('1' == self::getOption('setup_next_step') && $current_tab != 'accounts') {
         $msg1 = __('You have not linked WP-Lister to your eBay account yet.', 'wplister');
         $msg2 = __('To complete the setup procedure go to %s and follow the instructions.', 'wplister');
         $accounts_page = get_option('wplister_enable_accounts_page') ? 'wplister-settings-accounts' : 'wplister-settings&tab=accounts';
         $link = sprintf('<a href="admin.php?page=%s">%s</a>', $accounts_page, __('Account Settings', 'wplister'));
         $msg2 = sprintf($msg2, $link);
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
     } elseif ('2' == self::getOption('setup_next_step')) {
         $title = __('Setup - Step 2', 'wplister');
         $msg1 = __('Before creating your first profile, we need to download certain information which are specific to the eBay site you selected.', 'wplister');
         $msg2 = __('This includes shipping options, payment methods, your custom store categories as well as the whole eBay category tree, which might take a while.', 'wplister');
         // old button
         // $button = '<a href="#" id="btn_update_ebay_data" onclick="return false;" class="button-primary">'.__('Update eBay details','wplister').'</a>';
         // new button - use site_id of default (first) account
         $account = WPLE()->accounts[get_option('wplister_default_account_id')];
         $button = '<a href="#" data-site_id="' . $account->site_id . '" data-account_id="' . $account->id . '" class="btn_update_ebay_data_for_site button-primary">' . __('Refresh eBay details', 'wplister') . '</a>';
         $msg = "<p><b>{$title}</b></p><p>{$msg1}</p><p>{$msg2}</p>";
         $msg .= $button;
         wple_show_message($msg, 'info');
         // // remember when WP-Lister was connected to an eBay account for the first time
         // update_option( 'ignore_orders_before_ts', time() );
     } elseif ('3' == self::getOption('setup_next_step')) {
         $tm = new TemplatesModel();
         $templates = $tm->getAll();
         if (sizeof($templates) > 0) {
             self::updateOption('setup_next_step', '4');
         } else {
             $title = __('Setup - Step 3', 'wplister');
             $msg1 = __('Create a default listing template.', 'wplister');
             $msg2 = __('To create your first listing template click on %s.', 'wplister') . '<br>';
             if (@$_GET['action'] == 'add_new_template') {
                 $msg2 = __('Replace the default text according to your requirements and save your template to continue.', 'wplister');
             }
             $link = '<a href="admin.php?page=wplister-templates&action=add_new_template">' . __('New Template', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<p><b>{$title}</b></p><p><b>{$msg1}</b></p><p>{$msg2}</p>";
             wple_show_message($msg, 'info');
         }
     } elseif ('4' == self::getOption('setup_next_step')) {
         $pm = new ProfilesModel();
         $profiles = $pm->getAll();
         if (sizeof($profiles) > 0) {
             self::updateOption('setup_next_step', '0');
         } else {
             $title = __('Setup - Step 4', 'wplister');
             $msg1 = __('The final step: create your first listing profile.', 'wplister');
             $msg2 = __('Click on %s and start defining your listing options.<br>After saving your profile, visit your Products page and select the products to list on eBay.', 'wplister');
             $link = '<a href="admin.php?page=wplister-profiles&action=add_new_profile">' . __('New Profile', 'wplister') . '</a>';
             $msg2 = sprintf($msg2, $link);
             $msg = "<b>{$msg1}</b></p><p>{$msg2}";
             wple_show_message($msg, 'info');
         }
     } elseif ('5' == self::getOption('setup_next_step')) {
         $title = __('Setup is complete.', 'wplister');
         $msg1 = __('You are ready now to list your first items.', 'wplister');
         $msg2 = __('Visit your Products page, select a few items and select "List on eBay" from the bulk actions menu.', 'wplister');
         $msg = "<b>{$msg1}</b></p><p>{$msg2}";
         wple_show_message($msg, 'info');
         update_option('wplister_setup_next_step', '0');
     }
     // db upgrade
     WPLE_UpgradeHelper::upgradeDB();
     // check token expiration date
     self::checkToken();
     // check if all db tables exist
     self::checkDatabaseTables($page);
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_user') ) ) {
     // 	$this->initEC();
     // 	$UserID = $this->EC->GetUser();
     // 	$this->EC->closeEbay();
     // }
     // // fetch user details if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_seller_profiles_enabled') ) ) {
     // 	$this->initEC();
     // 	$this->EC->GetUserPreferences();
     // 	$this->EC->closeEbay();
     // }
     // // fetch token expiration date if not done yet
     // if ( ( self::getOption('ebay_token') != '' ) && ( ! self::getOption('ebay_token_expirationtime') ) ) {
     // 	$this->initEC();
     // 	$expdate = $this->EC->GetTokenStatus();
     // 	$this->EC->closeEbay();
     // }
 }
コード例 #4
0
 public function runInitialDbUpgrade()
 {
     // db upgrade
     WPLE_UpgradeHelper::upgradeDB();
 }