/** * Runs the export process. * * Passing in true will delete all the posts provided in the constructor. * * @param bool|false $delete */ public function run($delete = false) { $this->tree->fetch_last(); if (!$this->tree->is_ready()) { WordPress_GitHub_Sync::write_log(sprintf(__('Failed getting tree with error: %s', 'wordpress-github-sync'), $this->tree->last_error())); return; } WordPress_GitHub_Sync::write_log(__('Building the tree.', 'wordpress-github-sync')); foreach ($this->ids as $post_id) { $post = new WordPress_GitHub_Sync_Post($post_id); $this->tree->post_to_tree($post, $delete); } $result = $this->tree->export($this->msg); if (!$result) { $this->no_change(); return; } if (is_wp_error($result)) { $this->error($result); return; } $this->tree->fetch_last(); // @todo what if we fail? if ($this->tree->is_ready()) { WordPress_GitHub_Sync::write_log(__('Saving the shas.', 'wordpress-github-sync')); $this->save_post_shas(); } $this->success(); }