/** * Bulk actions */ public function bulk() { check_admin_referer('bulk-imports', '_wpnonce_bulk-imports'); if ($this->input->post('doaction2')) { $this->data['action'] = $action = $this->input->post('bulk-action2'); } else { $this->data['action'] = $action = $this->input->post('bulk-action'); } $this->data['ids'] = $ids = $this->input->post('items'); $this->data['items'] = $items = new PMXI_History_List(); if (empty($action) or !in_array($action, array('delete')) or empty($ids) or $items->getBy('id', $ids)->isEmpty()) { wp_redirect($this->baseUrl); die; } foreach ($items->convertRecords() as $item) { $item->delete(); } $id = $this->input->get('id'); wp_redirect(add_query_arg(array('id' => $id, 'pmxi_nt' => urlencode(sprintf(__('<strong>%d</strong> %s deleted', 'pmxi_plugin'), $items->count(), _n('history', 'histories', $items->count(), 'pmxi_plugin')))), $this->baseUrl)); die; }
/** * Delete associated history logs * @return PMXI_Import_Record * @chainable */ public function deleteHistories() { $historyList = new PMXI_History_List(); foreach ($historyList->getBy('import_id', $this->id)->convertRecords() as $h) { $h->delete(); } return $this; }