/** * Remove posts that has been deleted on content stage. * * Runs on production server after batch has been sent from content stage * and received by the production server. * * @param array $posts * @param Batch $batch */ public function import($posts, Batch $batch) { // No posts provided. if (empty($posts)) { return; } // String of deleted post IDs. $stage_post_ids = array(); foreach ($posts as $post) { if (!isset($post['guid'])) { continue; } $post_id = $this->api->get_post_id_by_guid($post['guid']); wp_delete_post($post_id, true); if (isset($post['id'])) { array_push($stage_post_ids, $post['id']); } } // String of deleted content staging IDs. $str = implode(',', $stage_post_ids); // Current blog ID. $blog_id = get_current_blog_id(); $message = sprintf('Posts deleted on Content Stage has been removed from Production. <span class="hidden" data-blog-id="%d">%s</span>', $blog_id, $str); $this->api->add_deploy_message($batch->get_id(), $message, 'info', 104); }