public function findMissingProducts() { $items = WPLA_ListingQueryHelper::findMissingProducts(); $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : false; if ($mode == 'delete') { foreach ($items as $item) { WPLA_ListingsModel::deleteItem($item->id); } wpla_show_message(sizeof($items) . ' items have been deleted.'); return; } if ($mode == 'import') { foreach ($items as $item) { $data = array('status' => 'imported'); WPLA_ListingsModel::updateWhere(array('id' => $item->id), $data); } wpla_show_message(sizeof($items) . ' items have been added to the import queue.'); return; } if (!empty($items)) { $nonce = wp_create_nonce('wpla_tools_page'); $btn_delete = '<a href="admin.php?page=wpla-tools&tab=inventory&action=wpla_check_for_missing_products&mode=delete&_wpnonce=' . $nonce . '" class="button button-small button-secondary">' . 'Delete all from DB' . '</a> '; $btn_import = '<a href="admin.php?page=wpla-tools&tab=inventory&action=wpla_check_for_missing_products&mode=import&_wpnonce=' . $nonce . '" class="button button-small button-primary" >' . 'Add to import queue' . '</a>'; $buttons = ' ' . $btn_delete . $btn_import; wpla_show_message('There are ' . sizeof($items) . ' listing(s) without a linked product in WooCommerce.' . $buttons, 'error'); } else { wpla_show_message('No missing products found.'); } }