Example #1
0
 /**
  * Download dropin file from given url and save it to in wp-content folder.
  *
  * @param string $url
  * @param string $dest
  */
 private function download($url, $dest)
 {
     $remote = new UrlDownloader($url);
     $name = basename($dest);
     if (!$remote->save($dest)) {
         $this->error .= "Impossible to download and save {$name}: " . $remote->error();
     } else {
         $this->success .= "<comment>{$name}</comment> downloaded and saved successfully.";
     }
 }
Example #2
0
 /**
  * Download a remote .env.example in root folder.
  *
  * @param  string       $url
  * @param  string       $dest
  * @param  \ArrayAccess $paths
  * @return int
  */
 private function download($url, $dest, ArrayAccess $paths)
 {
     if (!UrlDownloader::checkSoftware()) {
         $this->io->comment('WP Starter needs cUrl installed to download files from url.');
         return $this->copy($paths, $dest);
     }
     $remote = new UrlDownloader($url);
     if (!$remote->save($dest)) {
         $this->error = 'Error on downloading and save .env.example: ' . $remote->error() . '.';
         return self::ERROR;
     }
     return self::SUCCESS;
 }
Example #3
0
 /**
  * Download .gitignore from a given url.
  *
  * @param  \ArrayAccess $paths
  * @return int
  */
 private function download(ArrayAccess $paths)
 {
     if (!UrlDownloader::checkSoftware()) {
         $this->io->comment('WP Starter needs cUrl installed to download files from url.');
         return $this->create($paths);
     }
     $remote = new UrlDownloader($this->config);
     if ($remote->save($this->targetPath($paths))) {
         return self::SUCCESS;
     }
     $this->error = 'Error on downloading and saving .gitignore. ' . $remote->error();
     return self::ERROR;
 }
Example #4
0
 /**
  * Fetch languages from wordpress.org API.
  *
  * @param  bool       $ssl
  * @return array|bool
  */
 private function fetchLanguages($ssl = true)
 {
     static $languages;
     if (!is_null($languages)) {
         return $languages;
     }
     $url = $ssl ? 'https' : 'http';
     $url .= '://api.wordpress.org/translations/core/1.0/?version=';
     $remote = new UrlDownloader($url . $this->config['wp-version']);
     $result = $remote->fetch(true);
     if (!$result) {
         return $ssl ? $this->fetchLanguages(false) : false;
     }
     try {
         $all = (array) json_decode($result, true);
         $languages = isset($all['translations']) ? array() : false;
         if (is_array($languages)) {
             foreach ($all['translations'] as $lang) {
                 $languages[] = $lang['language'];
             }
         }
     } catch (Exception $e) {
         $languages = false;
     }
     if ($languages === false) {
         $this->io->comment('Error on loading languages from wordpress.org');
     }
     return $languages;
 }