示例#1
0
 public function run_post_hook()
 {
     if (isset(self::$config->post_hook)) {
         $result = Runner::get_result(self::$config->post_hook);
         if (!empty($result)) {
             var_dump($result);
         }
         WP_Cli::line("Ran post hook.");
     }
 }
 /**
  * Download a remote site.
  * 
  * @subcommand download
  * @synopsis --site-id=<site-id> [--type=<type>]
  */
 public function download($args, $assoc_args)
 {
     $site_id = $assoc_args['site-id'];
     $this->set_account();
     if (empty($assoc_args['type'])) {
         $assoc_args['type'] = 'complete';
     }
     WP_CLI::line(sprintf("Initiating %s archive.", $assoc_args['type']));
     $args = array('endpoint' => '/site/' . $site_id . '/download', 'method' => 'POST', 'body' => array('type' => $assoc_args['type']));
     $response = $this->api_request($args);
     if (is_wp_error($response)) {
         WP_CLI::error($response->get_error_message());
     }
     do {
         $args = array('endpoint' => '/site/' . $site_id . '/download', 'method' => 'GET');
         $response = $this->api_request($args);
         if (!is_wp_error($response) && !empty($response->status) && $response->status == 'error-status') {
             WP_Cli::line('Backup status: ' . strip_tags($response->backup_progress));
             sleep(15);
         }
     } while (!is_wp_error($response) && $response->status != 'backup-complete');
     if (is_wp_error($response)) {
         WP_CLI::error($response->get_error_message());
     }
     WP_CLI::launch(sprintf("wget '%s'", $response->url));
     WP_CLI::success("Site downloaded.");
 }