Пример #1
0
 /**
  * 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->ready()) {
         WordPress_GitHub_Sync::write_log(__('Failed getting tree with error: ', '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->ready()) {
         WordPress_GitHub_Sync::write_log(__('Saving the shas.', 'wordpress-github-sync'));
         $this->save_post_shas();
     }
     $this->success();
 }
Пример #2
0
 /**
  * Runs the import process for a provided sha.
  *
  * @param string $sha
  */
 public function run($sha)
 {
     $this->tree->fetch_sha($sha);
     if (!$this->tree->ready()) {
         WordPress_GitHub_Sync::write_log(__('Failed getting recursive tree with error: ', 'wordpress-github-sync') . $this->tree->last_error());
         return;
     }
     foreach ($this->tree as $blob) {
         $this->import_blob($blob);
     }
     WordPress_GitHub_Sync::write_log(__('Imported tree ', 'wordpress-github-sync') . $sha);
 }