/** * Generate an import key that can be used in background imports. * * @param Batch $batch * * @return string * * @throws Exception */ public function generate_import_key(Batch $batch) { if (!$batch->get_id() || !$batch->get_modified_gmt()) { throw new Exception('Failed generating batch import key.'); } $key = md5($batch->get_id() . '-' . $batch->get_modified_gmt() . '-' . rand(0, 100000)); update_post_meta($batch->get_id(), '_sme_import_key', $key); return $key; }