/** * Take content of a batch (attachments, users, post, custom data) and * inserted into database. * * @param Batch $batch */ private function update_batch_content(Batch $batch) { $content = array('attachments' => $batch->get_attachments(), 'users' => $batch->get_users(), 'posts' => $batch->get_posts(), 'options' => $batch->get_options(), 'custom_data' => $batch->get_custom_data(), 'post_rel_keys' => $batch->get_post_rel_keys()); $content = base64_encode(serialize($content)); update_post_meta($batch->get_id(), '_sme_batch_content', $content); }
/** * Pre-flight checks for a specific part of a batch. * * @param Batch $batch * @param string $type */ private function verify_by_type(Batch $batch, $type) { // The data we want to verify. $batch_chunk = array(); // Get data we want to verify. switch ($type) { case 'attachments': $batch_chunk = $batch->get_attachments(); break; case 'users': $batch_chunk = $batch->get_users(); break; case 'posts': $batch_chunk = $batch->get_posts(); break; case 'options': $batch_chunk = $batch->get_options(); } // Verify selected part of batch. foreach ($batch_chunk as $item) { do_action('sme_verify_' . $type, $item, $batch); } }