public function handleActions() { // check action if (isset($_REQUEST['action'])) { // check_ebay_connection if ($_REQUEST['action'] == 'check_ebay_connection') { $msg = $this->checkEbayConnection(); // $this->showMessage( $msg ); return; } // custom debug code if ($_REQUEST['action'] == 'wple_debug_1') { global $wpdb; $post_title = 'this string is 256 characters long - which is 1 too many........................................................................................................................................................................................................'; // $post_title = 'TEST'; $data = array(); $data['auction_title'] = $post_title; $data['status'] = 'TEST'; $table = $wpdb->prefix . 'ebay_auctions'; $result = $wpdb->insert($table, $data); echo "<pre>result: "; print_r($result); echo "</pre>"; #die(); echo "<pre>length: "; print_r(strlen($post_title)); echo "</pre>"; #die(); echo "<pre>insert_id: "; print_r($wpdb->insert_id); echo "</pre>"; #die(); echo "<pre>last query: "; print_r($wpdb->last_query); echo "</pre>"; #die(); return; } // check nonce if (check_admin_referer('e2e_tools_page')) { // check_ebay_time_offset if ($_REQUEST['action'] == 'check_ebay_time_offset') { $this->checkEbayTimeOffset(); } // view_logfile if ($_REQUEST['action'] == 'view_logfile') { $this->viewLogfile(); } // wplister_clear_log if ($_REQUEST['action'] == 'wplister_clear_log') { $this->clearLogfile(); $this->showMessage('Log file was cleared.'); } // check_wc_out_of_sync if ($_REQUEST['action'] == 'check_wc_out_of_sync') { require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php'; $ic = new WPL_InventoryCheck(); $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'published'; $prices = isset($_REQUEST['prices']) ? $_REQUEST['prices'] : false; $mark_as_changed = isset($_REQUEST['mark_as_changed']) ? $_REQUEST['mark_as_changed'] : false; $step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 0; $batch_size = get_option('wplister_inventory_check_batch_size', 200); // check new batch of items $new_items_were_processed = $ic->checkProductInventory($mode, $prices, $step); if ($new_items_were_processed) { // continue with step+1 $msg = 'Checking inventory, please wait... '; if ($mark_as_changed == 'yes') { $msg = 'Updating listing status, please wait... '; } $msg .= '<img src="' . WPLISTER_URL . '/img/ajax-loader.gif" style="float:left; margin-right:1em; margin-top:0.3em;"/>'; $step++; $msg .= '<br><small>Step ' . $step . ' / ' . $step * $batch_size . ' items checked </small>'; // build button, which is triggered by js automatically $url = 'admin.php?page=wplister-tools&action=check_wc_out_of_sync&mode=' . $mode . '&prices=' . $prices . '&mark_as_changed=' . $mark_as_changed . '&step=' . $step . '&_wpnonce=' . wp_create_nonce('e2e_tools_page'); $msg .= '<a href="' . $url . '" id="wple_auto_next_step" class="button" style="display:none">Next</a>'; wple_show_message($msg); } else { // show results $ic->showProductInventoryCheckResult($mode); // clear tmp data update_option('wple_inventory_check_queue_data', '', 'no'); } } // check_wc_out_of_sync // check_wc_out_of_stock if ($_REQUEST['action'] == 'check_wc_out_of_stock') { require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php'; $ic = new WPL_InventoryCheck(); $mark_as_changed = isset($_REQUEST['mark_as_changed']) ? $_REQUEST['mark_as_changed'] : false; $step = isset($_REQUEST['step']) ? $_REQUEST['step'] : 0; $batch_size = get_option('wplister_inventory_check_batch_size', 200); // check new batch of items $new_items_were_processed = $ic->checkProductStock($step); if ($new_items_were_processed) { // continue with step+1 $msg = 'Checking for out of stock products, please wait... '; if ($mark_as_changed == 'yes') { $msg = 'Updating listing status, please wait... '; } $msg .= '<img src="' . WPLISTER_URL . '/img/ajax-loader.gif" style="float:left; margin-right:1em; margin-top:0.3em;"/>'; $step++; $msg .= '<br><small>Step ' . $step . ' / ' . $step * $batch_size . ' items checked </small>'; // build button, which is triggered by js automatically $url = 'admin.php?page=wplister-tools&action=check_wc_out_of_stock&mark_as_changed=' . $mark_as_changed . '&step=' . $step . '&_wpnonce=' . wp_create_nonce('e2e_tools_page'); $msg .= '<a href="' . $url . '" id="wple_auto_next_step" class="button" style="display:none">Next</a>'; wple_show_message($msg); } else { // show results $ic->showProductStockCheckResult(); // clear tmp data update_option('wple_inventory_check_queue_data', '', 'no'); } } // check_wc_out_of_stock // check_wc_sold_stock if ($_REQUEST['action'] == 'check_wc_sold_stock') { require_once WPLISTER_PATH . '/classes/core/WPL_InventoryCheck.php'; $ic = new WPL_InventoryCheck(); $ic->checkSoldStock(); } // check_ebay_image_requirements if ($_REQUEST['action'] == 'check_ebay_image_requirements') { $this->checkProductImages(); } // check_missing_ebay_transactions if ($_REQUEST['action'] == 'check_missing_ebay_transactions') { $this->checkTransactions(true); } // fix_cog_on_imported_orders if ($_REQUEST['action'] == 'fix_cog_on_imported_orders') { $this->fixCostOfGoods(); } // lock_all_listings if ($_REQUEST['action'] == 'lock_all_listings') { $count = WPLE_ListingQueryHelper::lockAll(1); $this->showMessage($count . ' ' . 'items were locked.'); } // unlock_all_listings if ($_REQUEST['action'] == 'unlock_all_listings') { $count = WPLE_ListingQueryHelper::lockAll(0); $this->showMessage($count . ' ' . 'items were unlocked.'); } // import_wpla_product_ids if ($_REQUEST['action'] == 'import_wpla_product_ids') { $count = self::importWplaProductIds(); } // assign_all_data_to_default_account if ($_REQUEST['action'] == 'assign_all_data_to_default_account') { WPL_Setup::assignAllDataToDefaultAccount(); $this->showMessage(sprintf('All listings, orders and profiles have been assigned to your default account %s.', get_option('wplister_default_account_id'))); } // GetTokenStatus if ($_REQUEST['action'] == 'GetTokenStatus') { $this->initEC(); $expdate = $this->EC->GetTokenStatus(); $this->EC->closeEbay(); $msg = __('Your token will expire on', 'wplister') . ' ' . $expdate; $msg .= ' (' . human_time_diff(strtotime($expdate)) . ' from now)'; $this->showMessage($msg); } // GetUser if ($_REQUEST['action'] == 'GetUser') { $this->initEC(); $UserID = $this->EC->GetUser(); $this->EC->GetUserPreferences(); $this->EC->closeEbay(); $this->showMessage(__('Your UserID is', 'wplister') . ' ' . $UserID); } // GetNotificationPreferences if ($_REQUEST['action'] == 'GetNotificationPreferences') { $this->initEC(); $debug = $this->EC->GetNotificationPreferences(); $this->EC->closeEbay(); wple_show_message('<pre>' . print_r($debug, 1) . '</pre>'); } // EnableUserNotificationPreferences if ($_REQUEST['action'] == 'EnableUserNotificationPreferences') { $this->initEC(); $debug = $this->EC->SetUserNotificationPreferences('Enable'); $this->EC->closeEbay(); wple_show_message('<pre>' . print_r($debug, 1) . '</pre>'); } // DisableUserNotificationPreferences if ($_REQUEST['action'] == 'DisableUserNotificationPreferences') { $this->initEC(); $debug = $this->EC->SetUserNotificationPreferences('Disable'); $this->EC->closeEbay(); wple_show_message('<pre>' . print_r($debug, 1) . '</pre>'); } // ResetNotificationPreferences if ($_REQUEST['action'] == 'ResetNotificationPreferences') { $this->initEC(); $debug = $this->EC->ResetNotificationPreferences(); $this->EC->closeEbay(); wple_show_message('<pre>' . print_r($debug, 1) . '</pre>'); } // GetNotificationsUsage if ($_REQUEST['action'] == 'GetNotificationsUsage') { $this->initEC(); $debug = $this->EC->GetNotificationsUsage(); $this->EC->closeEbay(); wple_show_message('<pre>' . print_r($debug, 1) . '</pre>'); } // update_ebay_transactions if ($_REQUEST['action'] == 'update_ebay_transactions_30') { $this->initEC(); $tm = $this->EC->loadTransactions(30); $this->EC->updateListings(); $this->EC->closeEbay(); // show transaction report $msg = $tm->count_total . ' ' . __('Transactions were loaded from eBay.', 'wplister') . '<br>'; $msg .= __('Timespan', 'wplister') . ': ' . $tm->getHtmlTimespan(); $msg .= ' '; $msg .= '<a href="#" onclick="jQuery(\'#transaction_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $tm->getHtmlReport(); $this->showMessage($msg); } // update_ebay_orders if ($_REQUEST['action'] == 'update_ebay_orders_30') { $this->initEC(); $om = $this->EC->loadEbayOrders(30); $this->EC->updateListings(); $this->EC->closeEbay(); // show report $msg = $om->count_total . ' ' . __('Orders were loaded from eBay.', 'wplister') . '<br>'; $msg .= __('Timespan', 'wplister') . ': ' . $om->getHtmlTimespan(); $msg .= ' '; $msg .= '<a href="#" onclick="jQuery(\'.ebay_order_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>'; $msg .= $om->getHtmlReport(); $this->showMessage($msg); } // wple_upgrade_tables_to_utf8mb4 if ($_REQUEST['action'] == 'wple_upgrade_tables_to_utf8mb4') { $this->upgradeTablesUTF8MB4(); } // wple_run_daily_schedule if ($_REQUEST['action'] == 'wple_run_daily_schedule') { do_action('wple_daily_schedule'); } // wple_run_update_schedule if ($_REQUEST['action'] == 'wple_run_update_schedule') { do_action('wplister_update_auctions'); } } else { die('not allowed'); } } // if $_REQUEST['action'] }